mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 10:07:12 +00:00
Added support for namespace expansion of a DocBlock and via the DocBlock to its tags
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
namespace phpDocumentor\Reflection;
|
||||
|
||||
require_once __DIR__.'/../../../src/phpDocumentor/Reflection/DocBlock.php';
|
||||
require_once __DIR__.'/../../../src/phpDocumentor/Reflection/DocBlock/LongDescription.php';
|
||||
require_once __DIR__
|
||||
.'/../../../src/phpDocumentor/Reflection/DocBlock/LongDescription.php';
|
||||
|
||||
/**
|
||||
* Test class for phpDocumentor_Reflection_DocBlock
|
||||
@@ -38,7 +39,8 @@ DOCBLOCK;
|
||||
'This is a short description.', $object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This is a long description.', $object->getLongDescription()->getContents()
|
||||
'This is a long description.',
|
||||
$object->getLongDescription()->getContents()
|
||||
);
|
||||
$this->assertEquals(2, count($object->getTags()));
|
||||
$this->assertTrue($object->hasTag('see'));
|
||||
@@ -58,8 +60,89 @@ DOCBLOCK;
|
||||
'This is a short description.', $object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals(
|
||||
"This is a long description.\nThis is a continuation of the long description.", $object->getLongDescription()->getContents()
|
||||
);
|
||||
"This is a long description.\nThis is a continuation of the long "
|
||||
."description.", $object->getLongDescription()->getContents()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether a type is expanded with the given namespace and that a
|
||||
* keyword is not expanded.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExpandTypeUsingNamespace()
|
||||
{
|
||||
$docblock = new DocBlock('', '\My\Namespace');
|
||||
$this->assertEquals('\My\Namespace\Mine', $docblock->expandType('Mine'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether a type is expanded when no namespace is given.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExpandTypeWithoutNamespace()
|
||||
{
|
||||
$docblock = new DocBlock('');
|
||||
$this->assertEquals('\Mine', $docblock->expandType('Mine'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether a type is expanded with the given namespace when an alias
|
||||
* is provided.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExpandTypeUsingNamespaceAlias()
|
||||
{
|
||||
$docblock = new DocBlock(
|
||||
'', '\My\Namespace', array('Alias' => '\My\Namespace\Alias')
|
||||
);
|
||||
|
||||
// first try a normal resolution without alias
|
||||
$this->assertEquals(
|
||||
'\My\Namespace\Al', $docblock->expandType('Al')
|
||||
);
|
||||
|
||||
// try to use the alias
|
||||
$this->assertEquals(
|
||||
'\My\Namespace\Alias\Al', $docblock->expandType('Alias\Al')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the keywords that should not be converted are not converted.
|
||||
*
|
||||
* @param string $keyword The keyword that is to be tested; this is provided
|
||||
* by the dataprovider.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
||||
*
|
||||
* @dataProvider getNonExpandableKeywordsForExpandType
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testThatExpandTypeDoesNotExpandAllKeywords($keyword)
|
||||
{
|
||||
$docblock = new DocBlock('', '\My\Namespace');
|
||||
$this->assertEquals($keyword, $docblock->expandType($keyword));
|
||||
}
|
||||
|
||||
public function getNonExpandableKeywordsForExpandType()
|
||||
{
|
||||
return array(
|
||||
array('string'), array('int'), array('integer'), array('bool'),
|
||||
array('boolean'), array('float'), array('double'), array('object'),
|
||||
array('mixed'), array('array'), array('resource'), array('void'),
|
||||
array('null'), array('callback'), array('false'), array('true')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user