コード例 #1
0
 /**
  * @dataProvider extractorsDataProvider
  *
  * @param $class
  * @param $extractor
  * @param $properties
  */
 public function testExtractors($class, $extractor, $properties)
 {
     /** @var TypeExtractorInterface|DescriptionExtractorInterface $extractor */
     $extractor = new $extractor();
     $propertyInfo = new PropertyInfo([$extractor], [$extractor]);
     foreach ($properties as $property) {
         $reflectionProperty = new \ReflectionProperty($class, $property['name']);
         $expectedType = $property['type'];
         /** @var Type[] $actualTypes */
         $actualTypes = $propertyInfo->getTypes($reflectionProperty);
         $actualType = $actualTypes[0];
         if (isset($property['short_description'])) {
             $this->assertEquals($property['short_description'], $propertyInfo->getShortDescription($reflectionProperty));
         }
         if (isset($property['long_description'])) {
             $this->assertEquals($property['long_description'], $propertyInfo->getLongDescription($reflectionProperty));
         }
         if ($expectedType !== null) {
             $this->assertEquals($expectedType, $actualType->getType());
             $this->assertEquals($property['class'], $actualType->getClass());
             $this->assertEquals($property['collection'], $actualType->isCollection());
             if (isset($property['collectionType'])) {
                 $actualCollectionType = $actualType->getCollectionType();
                 $this->assertEquals($property['collectionType']['type'], $actualCollectionType->getType());
                 $this->assertEquals($property['collectionType']['class'], $actualCollectionType->getClass());
                 $this->assertEquals($property['collectionType']['collection'], $actualCollectionType->isCollection());
             }
         } else {
             $this->assertNull($actualType);
         }
     }
 }
コード例 #2
0
 public function testGetLongDescription()
 {
     $this->assertSame('long', $this->propertyInfo->getLongDescription('Foo', 'bar', array()));
 }