[PropertyInfo] fix tests

This commit is contained in:
Christian Flothmann 2018-02-09 19:31:25 +01:00
parent 2ab947f8f1
commit 00cdec9ea2
2 changed files with 29 additions and 29 deletions

View File

@ -40,31 +40,6 @@ class PhpDocExtractorTest extends TestCase
$this->assertSame($longDescription, $this->extractor->getLongDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property)); $this->assertSame($longDescription, $this->extractor->getLongDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
} }
public function testParamTagTypeIsOmitted()
{
$this->assertNull($this->extractor->getTypes(OmittedParamTagTypeDocBlock::class, 'omittedType'));
}
/**
* @dataProvider typesWithCustomPrefixesProvider
*/
public function testExtractTypesWithCustomPrefixes($property, array $type = null)
{
$customExtractor = new PhpDocExtractor(null, array('add', 'remove'), array('is', 'can'));
$this->assertEquals($type, $customExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
}
/**
* @dataProvider typesWithNoPrefixesProvider
*/
public function testExtractTypesWithNoPrefixes($property, array $type = null)
{
$noPrefixExtractor = new PhpDocExtractor(null, array(), array(), array());
$this->assertEquals($type, $noPrefixExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
}
public function typesProvider() public function typesProvider()
{ {
return array( return array(
@ -102,6 +77,21 @@ class PhpDocExtractorTest extends TestCase
); );
} }
public function testParamTagTypeIsOmitted()
{
$this->assertNull($this->extractor->getTypes(OmittedParamTagTypeDocBlock::class, 'omittedType'));
}
/**
* @dataProvider typesWithCustomPrefixesProvider
*/
public function testExtractTypesWithCustomPrefixes($property, array $type = null)
{
$customExtractor = new PhpDocExtractor(null, array('add', 'remove'), array('is', 'can'));
$this->assertEquals($type, $customExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
}
public function typesWithCustomPrefixesProvider() public function typesWithCustomPrefixesProvider()
{ {
return array( return array(
@ -130,13 +120,23 @@ class PhpDocExtractorTest extends TestCase
array('d', array(new Type(Type::BUILTIN_TYPE_BOOL)), null, null), array('d', array(new Type(Type::BUILTIN_TYPE_BOOL)), null, null),
array('e', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_RESOURCE))), null, null), array('e', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_RESOURCE))), null, null),
array('f', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null), array('f', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime'))), null, null),
array('g', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)), 'Nullable array.', null), array('g', null),
array('donotexist', null, null, null), array('donotexist', null, null, null),
array('staticGetter', null, null, null), array('staticGetter', null, null, null),
array('staticSetter', null, null, null), array('staticSetter', null, null, null),
); );
} }
/**
* @dataProvider typesWithNoPrefixesProvider
*/
public function testExtractTypesWithNoPrefixes($property, array $type = null)
{
$noPrefixExtractor = new PhpDocExtractor(null, array(), array(), array());
$this->assertEquals($type, $noPrefixExtractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
}
public function typesWithNoPrefixesProvider() public function typesWithNoPrefixesProvider()
{ {
return array( return array(
@ -165,7 +165,7 @@ class PhpDocExtractorTest extends TestCase
array('d', null, null, null), array('d', null, null, null),
array('e', null, null, null), array('e', null, null, null),
array('f', null, null, null), array('f', null, null, null),
array('g', array(new Type(Type::BUILTIN_TYPE_ARRAY, true, null, true)), 'Nullable array.', null), array('g', null),
array('donotexist', null, null, null), array('donotexist', null, null, null),
array('staticGetter', null, null, null), array('staticGetter', null, null, null),
array('staticSetter', null, null, null), array('staticSetter', null, null, null),

View File

@ -73,7 +73,7 @@ class ReflectionExtractorTest extends TestCase
'collection', 'collection',
'B', 'B',
'Guid', 'Guid',
'g', 'array',
'emptyVar', 'emptyVar',
'foo', 'foo',
'foo2', 'foo2',
@ -101,7 +101,7 @@ class ReflectionExtractorTest extends TestCase
'collection', 'collection',
'B', 'B',
'Guid', 'Guid',
'g', 'array',
'emptyVar', 'emptyVar',
'foo', 'foo',
'foo2', 'foo2',