mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-17 17:47:13 +00:00
Merge branch 'master' of github.com:boenrobot/ReflectionDocBlock into author
Conflicts: src/phpDocumentor/Reflection/DocBlock/Tag/AuthorTag.php
This commit is contained in:
+13
-13
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Long Description Test
|
||||
* phpDocumentor Description Test
|
||||
*
|
||||
* PHP Version 5.3
|
||||
*
|
||||
@@ -13,21 +13,21 @@
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
/**
|
||||
* Test class for phpDocumentor\Reflection\DocBlock\LongDescription
|
||||
* Test class for phpDocumentor\Reflection\DocBlock\Description
|
||||
*
|
||||
* @author Vasil Rangelov <boen.robot@gmail.com>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class LongDescriptionTest extends \PHPUnit_Framework_TestCase
|
||||
class DescriptionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConstruct()
|
||||
{
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -41,7 +41,7 @@ LONGDESC;
|
||||
This is text for a {@link http://phpdoc.org/ description} that uses inline
|
||||
tags.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -64,7 +64,7 @@ tags.',
|
||||
{@link http://phpdoc.org/ This} is text for a description that uses inline
|
||||
tags.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -88,7 +88,7 @@ tags.',
|
||||
This is text for a description with {@internal inline tag with
|
||||
{@link http://phpdoc.org another inline tag} in it}.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -119,7 +119,7 @@ LONGDESC;
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description containing { that is literal.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -133,7 +133,7 @@ LONGDESC;
|
||||
This is text for a description containing {@internal inline tag that has { that
|
||||
is literal}.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -160,7 +160,7 @@ is literal'),
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description with {} that is not a tag.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -177,7 +177,7 @@ LONGDESC;
|
||||
This is text for a description with {@internal inline tag with {} that is not an
|
||||
inline tag}.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -204,7 +204,7 @@ inline tag'),
|
||||
$fixture = <<<LONGDESC
|
||||
This is text for a description with literal {{@}link}.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -221,7 +221,7 @@ LONGDESC;
|
||||
This is text for a description with an {@internal inline tag with literal
|
||||
{{@}link{} in it}.
|
||||
LONGDESC;
|
||||
$object = new LongDescription($fixture);
|
||||
$object = new Description($fixture);
|
||||
$this->assertSame($fixture, $object->getContents());
|
||||
|
||||
$parsedContents = $object->getParsedContents();
|
||||
@@ -28,11 +28,10 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exName
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\CoversTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\CoversTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
@@ -40,22 +39,16 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exName,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exReference
|
||||
) {
|
||||
$tag = new CoversTag($type, $content);
|
||||
|
||||
$actualName = $tag->getName();
|
||||
$actualContent = $tag->getContent();
|
||||
$actualDescription = $tag->getDescription();
|
||||
$actualReference = $tag->getReference();
|
||||
|
||||
$this->assertEquals($exName, $actualName);
|
||||
$this->assertEquals($exContent, $actualContent);
|
||||
$this->assertEquals($exDescription, $actualDescription);
|
||||
$this->assertEquals($exReference, $actualReference);
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exReference, $tag->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,28 +58,25 @@ class CoversTagTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exName, $exContent, $exDescription, $exReference
|
||||
// $type, $content, $exContent, $exDescription, $exReference
|
||||
return array(
|
||||
array(
|
||||
'uses',
|
||||
'covers',
|
||||
'Foo::bar()',
|
||||
'uses',
|
||||
'Foo::bar()',
|
||||
'',
|
||||
'Foo::bar()'
|
||||
),
|
||||
array(
|
||||
'uses',
|
||||
'covers',
|
||||
'Foo::bar() Testing',
|
||||
'uses',
|
||||
'Foo::bar() Testing',
|
||||
'Testing',
|
||||
'Foo::bar()',
|
||||
),
|
||||
array(
|
||||
'uses',
|
||||
'covers',
|
||||
'Foo::bar() Testing comments',
|
||||
'uses',
|
||||
'Foo::bar() Testing comments',
|
||||
'Testing comments',
|
||||
'Foo::bar()',
|
||||
|
||||
@@ -28,12 +28,12 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exName
|
||||
* @param string $exContent
|
||||
* @param string $exDescription
|
||||
* @param string $exLink
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\LinkTag::getLink
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
@@ -41,22 +41,16 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exName,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exLink
|
||||
) {
|
||||
$tag = new LinkTag($type, $content);
|
||||
|
||||
$actualName = $tag->getName();
|
||||
$actualContent = $tag->getContent();
|
||||
$actualDescription = $tag->getDescription();
|
||||
$actualLink = $tag->getLink();
|
||||
|
||||
$this->assertEquals($exName, $actualName);
|
||||
$this->assertEquals($exContent, $actualContent);
|
||||
$this->assertEquals($exDescription, $actualDescription);
|
||||
$this->assertEquals($exLink, $actualLink);
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exLink, $tag->getLink());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,12 +60,11 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exName, $exContent, $exDescription, $exLink
|
||||
// $type, $content, $exContent, $exDescription, $exLink
|
||||
return array(
|
||||
array(
|
||||
'link',
|
||||
'http://www.phpdoc.org/',
|
||||
'link',
|
||||
'http://www.phpdoc.org/',
|
||||
'http://www.phpdoc.org/',
|
||||
'http://www.phpdoc.org/'
|
||||
@@ -79,7 +72,6 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
array(
|
||||
'link',
|
||||
'http://www.phpdoc.org/ Testing',
|
||||
'link',
|
||||
'http://www.phpdoc.org/ Testing',
|
||||
'Testing',
|
||||
'http://www.phpdoc.org/'
|
||||
@@ -87,7 +79,6 @@ class LinkTagTest extends \PHPUnit_Framework_TestCase
|
||||
array(
|
||||
'link',
|
||||
'http://www.phpdoc.org/ Testing comments',
|
||||
'link',
|
||||
'http://www.phpdoc.org/ Testing comments',
|
||||
'Testing comments',
|
||||
'http://www.phpdoc.org/'
|
||||
|
||||
@@ -23,17 +23,21 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @param string $signature The signature to test
|
||||
* @param string $signature The signature to test.
|
||||
* @param bool $valid Whether the given signature is expected to
|
||||
* be valid.
|
||||
* @param string $expected_name The method name that is expected from this
|
||||
* signature
|
||||
* signature.
|
||||
* @param string $expected_return The return type that is expected from this
|
||||
* signature
|
||||
* @param bool $has_params whether this signature features parameters.
|
||||
* signature.
|
||||
* @param bool $paramCount Number of parameters in the signature.
|
||||
* @param string $description The short description mentioned in the
|
||||
* signature.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::getMethodName
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\MethodTag::getArguments
|
||||
*
|
||||
* @dataProvider getTestSignatures
|
||||
*
|
||||
* @return void
|
||||
@@ -43,7 +47,7 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
$valid,
|
||||
$expected_name,
|
||||
$expected_return,
|
||||
$has_params,
|
||||
$paramCount,
|
||||
$description
|
||||
) {
|
||||
ob_start();
|
||||
@@ -63,11 +67,7 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expected_name, $tag->getMethodName());
|
||||
$this->assertEquals($expected_return, $tag->getType());
|
||||
$this->assertEquals($description, $tag->getDescription());
|
||||
$this->assertSame(
|
||||
$has_params,
|
||||
(bool)(count($tag->getArguments()) > 0),
|
||||
'Number of found arguments should exceed 0'
|
||||
);
|
||||
$this->assertCount($paramCount, $tag->getArguments());
|
||||
}
|
||||
|
||||
public function getTestSignatures()
|
||||
@@ -75,55 +75,55 @@ class MethodTagTest extends \PHPUnit_Framework_TestCase
|
||||
return array(
|
||||
array(
|
||||
'foo',
|
||||
false, 'foo', '', false, ''
|
||||
false, 'foo', '', 0, ''
|
||||
),
|
||||
array(
|
||||
'foo()',
|
||||
true, 'foo', 'void', false, ''
|
||||
true, 'foo', 'void', 0, ''
|
||||
),
|
||||
array(
|
||||
'foo() description',
|
||||
true, 'foo', 'void', false, 'description'
|
||||
true, 'foo', 'void', 0, 'description'
|
||||
),
|
||||
array(
|
||||
'int foo()',
|
||||
true, 'foo', 'int', false, ''
|
||||
true, 'foo', 'int', 0, ''
|
||||
),
|
||||
array(
|
||||
'int foo() description',
|
||||
true, 'foo', 'int', false, 'description'
|
||||
true, 'foo', 'int', 0, 'description'
|
||||
),
|
||||
array(
|
||||
'int foo($a, $b)',
|
||||
true, 'foo', 'int', true, ''
|
||||
true, 'foo', 'int', 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo() foo(int $a, int $b)',
|
||||
true, 'foo', 'int', true, ''
|
||||
true, 'foo', 'int', 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo(int $a, int $b)',
|
||||
true, 'foo', 'int', true, ''
|
||||
true, 'foo', 'int', 2, ''
|
||||
),
|
||||
array(
|
||||
'null|int foo(int $a, int $b)',
|
||||
true, 'foo', 'null|int', true, ''
|
||||
true, 'foo', 'null|int', 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo(null|int $a, int $b)',
|
||||
true, 'foo', 'int', true, ''
|
||||
true, 'foo', 'int', 2, ''
|
||||
),
|
||||
array(
|
||||
'\Exception foo() foo(Exception $a, Exception $b)',
|
||||
true, 'foo', '\Exception', true, ''
|
||||
true, 'foo', '\Exception', 2, ''
|
||||
),
|
||||
array(
|
||||
'int foo() foo(Exception $a, Exception $b) description',
|
||||
true, 'foo', 'int', true, 'description'
|
||||
true, 'foo', 'int', 2, 'description'
|
||||
),
|
||||
array(
|
||||
'int foo() foo(\Exception $a, \Exception $b) description',
|
||||
true, 'foo', 'int', true, 'description'
|
||||
true, 'foo', 'int', 2, 'description'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -29,10 +29,12 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $extractedType
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedVarName
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::getVariableName
|
||||
*
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
@@ -42,12 +44,15 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
$type,
|
||||
$content,
|
||||
$extractedType,
|
||||
$extractedTypes,
|
||||
$extractedVarName,
|
||||
$extractedDescription
|
||||
) {
|
||||
$tag = new ParamTag($type, $content);
|
||||
|
||||
$this->assertEquals($extractedType, $tag->getTypes());
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($extractedType, $tag->getType());
|
||||
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||
$this->assertEquals($extractedVarName, $tag->getVariableName());
|
||||
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||
}
|
||||
@@ -60,17 +65,56 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
|
||||
public function provideDataForConstructor()
|
||||
{
|
||||
return array(
|
||||
array('param', 'int', array('int'), '', ''),
|
||||
array('param', '$bob', array(), '$bob', ''),
|
||||
array('param', 'int', 'int', array('int'), '', ''),
|
||||
array('param', '$bob', '', array(), '$bob', ''),
|
||||
array(
|
||||
'param', 'int Number of bobs', array('int'), '',
|
||||
'param',
|
||||
'int Number of bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'',
|
||||
'Number of bobs'
|
||||
),
|
||||
array('param', 'int $bob', array('int'), '$bob', ''),
|
||||
array(
|
||||
'param', 'int $bob Number of bobs', array('int'), '$bob',
|
||||
'param',
|
||||
'int $bob',
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
''
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
'int $bob Number of bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
'Number of bobs'
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"int Description \n on multiple lines",
|
||||
'int',
|
||||
array('int'),
|
||||
'',
|
||||
"Description \n on multiple lines"
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"int \n\$bob Variable name on a new line",
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Variable name on a new line"
|
||||
),
|
||||
array(
|
||||
'param',
|
||||
"\nint \$bob Type on a new line",
|
||||
'int',
|
||||
array('int'),
|
||||
'$bob',
|
||||
"Type on a new line"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,30 +20,38 @@ namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ReturnTagTest extends ParamTagTest
|
||||
class ReturnTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag can
|
||||
* understand the @return DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $extractedType
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::getType
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::getTypes
|
||||
*
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParsesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$extractedType,
|
||||
$extractedTypes,
|
||||
$extractedDescription
|
||||
) {
|
||||
$tag = new ReturnTag('return', $content);
|
||||
$tag = new ReturnTag($type, $content);
|
||||
|
||||
$this->assertEquals($extractedType, $tag->getTypes());
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($extractedType, $tag->getType());
|
||||
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
@@ -55,9 +63,36 @@ class ReturnTagTest extends ParamTagTest
|
||||
public function provideDataForConstructor()
|
||||
{
|
||||
return array(
|
||||
array('', array(), ''),
|
||||
array('int', array('int'), ''),
|
||||
array('int Number of Bobs', array('int'), 'Number of Bobs'),
|
||||
array('return', '', '', array(), ''),
|
||||
array('return', 'int', 'int', array('int'), ''),
|
||||
array(
|
||||
'return',
|
||||
'int Number of Bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'Number of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
'int|double Number of Bobs',
|
||||
'int|double',
|
||||
array('int', 'double'),
|
||||
'Number of Bobs'
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
"int Number of \n Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of \n Bobs"
|
||||
),
|
||||
array(
|
||||
'return',
|
||||
" int Number of Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of Bobs"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exName
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\SeeTag::getReference
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
@@ -40,22 +40,16 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exName,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exReference
|
||||
) {
|
||||
$tag = new SeeTag($type, $content);
|
||||
|
||||
$actualName = $tag->getName();
|
||||
$actualContent = $tag->getContent();
|
||||
$actualDescription = $tag->getDescription();
|
||||
$actualReference = $tag->getReference();
|
||||
|
||||
$this->assertEquals($exName, $actualName);
|
||||
$this->assertEquals($exContent, $actualContent);
|
||||
$this->assertEquals($exDescription, $actualDescription);
|
||||
$this->assertEquals($exReference, $actualReference);
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exReference, $tag->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,28 +59,25 @@ class SeeTagTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exName, $exContent, $exDescription, $exReference
|
||||
// $type, $content, $exContent, $exDescription, $exReference
|
||||
return array(
|
||||
array(
|
||||
'uses',
|
||||
'see',
|
||||
'Foo::bar()',
|
||||
'uses',
|
||||
'Foo::bar()',
|
||||
'',
|
||||
'Foo::bar()'
|
||||
),
|
||||
array(
|
||||
'uses',
|
||||
'see',
|
||||
'Foo::bar() Testing',
|
||||
'uses',
|
||||
'Foo::bar() Testing',
|
||||
'Testing',
|
||||
'Foo::bar()',
|
||||
),
|
||||
array(
|
||||
'uses',
|
||||
'see',
|
||||
'Foo::bar() Testing comments',
|
||||
'uses',
|
||||
'Foo::bar() Testing comments',
|
||||
'Testing comments',
|
||||
'Foo::bar()',
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Return tag test.
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock\Tag;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\ReturnTag.
|
||||
*
|
||||
* @author Mike van Riel <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class ThrowsTagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag can
|
||||
* understand the @return DocBlock.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $extractedType
|
||||
* @param string $extractedTypes
|
||||
* @param string $extractedDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ThrowsTag
|
||||
*
|
||||
* @dataProvider provideDataForConstructor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParsesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$extractedType,
|
||||
$extractedTypes,
|
||||
$extractedDescription
|
||||
) {
|
||||
$tag = new ThrowsTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($extractedType, $tag->getType());
|
||||
$this->assertEquals($extractedTypes, $tag->getTypes());
|
||||
$this->assertEquals($extractedDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParsesInputsIntoCorrectFields()
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstructor()
|
||||
{
|
||||
return array(
|
||||
array('throws', '', '', array(), ''),
|
||||
array('throws', 'int', 'int', array('int'), ''),
|
||||
array(
|
||||
'throws',
|
||||
'int Number of Bobs',
|
||||
'int',
|
||||
array('int'),
|
||||
'Number of Bobs'
|
||||
),
|
||||
array(
|
||||
'throws',
|
||||
'int|double Number of Bobs',
|
||||
'int|double',
|
||||
array('int', 'double'),
|
||||
'Number of Bobs'
|
||||
),
|
||||
array(
|
||||
'throws',
|
||||
"int Number of \n Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of \n Bobs"
|
||||
),
|
||||
array(
|
||||
'throws',
|
||||
" int Number of Bobs",
|
||||
'int',
|
||||
array('int'),
|
||||
"Number of Bobs"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -28,11 +28,10 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exName
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
@@ -40,22 +39,16 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exName,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exReference
|
||||
) {
|
||||
$tag = new UsesTag($type, $content);
|
||||
|
||||
$actualName = $tag->getName();
|
||||
$actualContent = $tag->getContent();
|
||||
$actualDescription = $tag->getDescription();
|
||||
$actualReference = $tag->getReference();
|
||||
|
||||
$this->assertEquals($exName, $actualName);
|
||||
$this->assertEquals($exContent, $actualContent);
|
||||
$this->assertEquals($exDescription, $actualDescription);
|
||||
$this->assertEquals($exReference, $actualReference);
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exReference, $tag->getReference());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,12 +58,11 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exName, $exContent, $exDescription, $exReference
|
||||
// $type, $content, $exContent, $exDescription, $exReference
|
||||
return array(
|
||||
array(
|
||||
'uses',
|
||||
'Foo::bar()',
|
||||
'uses',
|
||||
'Foo::bar()',
|
||||
'',
|
||||
'Foo::bar()'
|
||||
@@ -78,7 +70,6 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
array(
|
||||
'uses',
|
||||
'Foo::bar() Testing',
|
||||
'uses',
|
||||
'Foo::bar() Testing',
|
||||
'Testing',
|
||||
'Foo::bar()',
|
||||
@@ -86,7 +77,6 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
|
||||
array(
|
||||
'uses',
|
||||
'Foo::bar() Testing comments',
|
||||
'uses',
|
||||
'Foo::bar() Testing comments',
|
||||
'Testing comments',
|
||||
'Foo::bar()',
|
||||
|
||||
@@ -46,6 +46,7 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||
) {
|
||||
$tag = new VarTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exType, $tag->getType());
|
||||
$this->assertEquals($exVariable, $tag->getVariableName());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
@@ -58,7 +59,7 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content
|
||||
// $type, $content, $exType, $exVariable, $exDescription
|
||||
return array(
|
||||
array(
|
||||
'var',
|
||||
@@ -81,6 +82,13 @@ class VarTagTest extends \PHPUnit_Framework_TestCase
|
||||
'$bob',
|
||||
'Number of bobs'
|
||||
),
|
||||
array(
|
||||
'var',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
''
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
/**
|
||||
* phpDocumentor Var Tag Test
|
||||
*
|
||||
* PHP version 5.3
|
||||
*
|
||||
* @author Daniel O'Connor <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
|
||||
namespace phpDocumentor\Reflection\DocBlock;
|
||||
|
||||
/**
|
||||
* Test class for \phpDocumentor\Reflection\DocBlock\Tag\VarTag
|
||||
*
|
||||
* @author Daniel O'Connor <[email protected]>
|
||||
* @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT
|
||||
* @link http://phpdoc.org
|
||||
*/
|
||||
class TagTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidTagLine()
|
||||
{
|
||||
Tag::createInstance('Invalid tag line');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagHandlerUnregistration()
|
||||
{
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
$tagPreUnreg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPreUnreg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreUnreg
|
||||
);
|
||||
|
||||
Tag::registerTagHandler('var', null);
|
||||
|
||||
$tagPostUnreg = Tag::createInstance('@var mixed');
|
||||
$this->assertNotInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPostUnreg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostUnreg
|
||||
);
|
||||
|
||||
Tag::registerTagHandler('var', $currentHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTagHandlerCorrectRegistration()
|
||||
{
|
||||
if (0 == ini_get('allow_url_include')) {
|
||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||
}
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
$tagPreUnreg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPreUnreg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreUnreg
|
||||
);
|
||||
|
||||
require 'data:text/plain;base64,'. base64_encode(
|
||||
<<<TAG_HANDLER
|
||||
<?php
|
||||
class MyVarHandler extends \phpDocumentor\Reflection\DocBlock\Tag {}
|
||||
TAG_HANDLER
|
||||
);
|
||||
|
||||
$this->assertTrue(Tag::registerTagHandler('var', '\MyVarHandler'));
|
||||
|
||||
$tagPostUnreg = Tag::createInstance('@var mixed');
|
||||
$this->assertNotInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPostUnreg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostUnreg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
'\MyVarHandler',
|
||||
$tagPostUnreg
|
||||
);
|
||||
|
||||
$this->assertTrue(Tag::registerTagHandler('var', $currentHandler));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNonExistentTagHandlerRegistration()
|
||||
{
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
$tagPreReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
$this->assertFalse(Tag::registerTagHandler('var', 'Non existent'));
|
||||
|
||||
$tagPostReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostReg
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::registerTagHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testIncompatibleTagHandlerRegistration()
|
||||
{
|
||||
$currentHandler = __NAMESPACE__ . '\Tag\VarTag';
|
||||
$tagPreReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPreReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPreReg
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
Tag::registerTagHandler('var', __NAMESPACE__ . '\TagTest')
|
||||
);
|
||||
|
||||
$tagPostReg = Tag::createInstance('@var mixed');
|
||||
$this->assertInstanceOf(
|
||||
$currentHandler,
|
||||
$tagPostReg
|
||||
);
|
||||
$this->assertInstanceOf(
|
||||
__NAMESPACE__ . '\Tag',
|
||||
$tagPostReg
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the \phpDocumentor\Reflection\DocBlock\Tag\VarTag can
|
||||
* understand the @var doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exDescription
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::__construct
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::getDescription
|
||||
* @covers \phpDocumentor\Reflection\DocBlock\Tag::getContent
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exDescription
|
||||
) {
|
||||
$tag = new Tag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($content, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exDescription
|
||||
return array(
|
||||
array(
|
||||
'unknown',
|
||||
'some content',
|
||||
'some content',
|
||||
),
|
||||
array(
|
||||
'unknown',
|
||||
'',
|
||||
'',
|
||||
),
|
||||
array(
|
||||
'',
|
||||
'unknown',
|
||||
'unknown',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,23 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertCount(0, $collection->getNamespaceAliases());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::setNamespace
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getNamespace
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::getNamespaceAliases
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testGlobalIgnore()
|
||||
{
|
||||
$collection = new Collection();
|
||||
$collection->setNamespace('global');
|
||||
$this->assertCount(0, $collection);
|
||||
$this->assertEquals('\\', $collection->getNamespace());
|
||||
$this->assertCount(0, $collection->getNamespaceAliases());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::__construct
|
||||
*
|
||||
@@ -118,8 +135,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fixture
|
||||
* @param $expected
|
||||
* @param string $fixture
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpand
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
@@ -137,8 +154,8 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $fixture
|
||||
* @param $expected
|
||||
* @param string $fixture
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpandWithoutNamespace
|
||||
* @covers phpDocumentor\Reflection\DocBlock\Type\Collection::add
|
||||
|
||||
@@ -34,7 +34,11 @@ class DocBlockTest extends \PHPUnit_Framework_TestCase
|
||||
* @return void
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$object = new DocBlock(
|
||||
$fixture,
|
||||
'\MyNamespace',
|
||||
array('PHPDoc' => '\phpDocumentor')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'This is a short description.',
|
||||
$object->getShortDescription()
|
||||
@@ -43,12 +47,62 @@ DOCBLOCK;
|
||||
'This is a long description.',
|
||||
$object->getLongDescription()->getContents()
|
||||
);
|
||||
$this->assertEquals(2, count($object->getTags()));
|
||||
$this->assertCount(2, $object->getTags());
|
||||
$this->assertTrue($object->hasTag('see'));
|
||||
$this->assertTrue($object->hasTag('return'));
|
||||
$this->assertFalse($object->hasTag('category'));
|
||||
|
||||
$this->assertSame('\MyNamespace', $object->getNamespace());
|
||||
$this->assertSame(
|
||||
array('PHPDoc' => '\phpDocumentor'),
|
||||
$object->getNamespaceAliases()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::splitDocBlock
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructWithTagsOnly()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* @see \MyClass
|
||||
* @return void
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals('', $object->getShortDescription());
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertCount(2, $object->getTags());
|
||||
$this->assertTrue($object->hasTag('see'));
|
||||
$this->assertTrue($object->hasTag('return'));
|
||||
$this->assertFalse($object->hasTag('category'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::cleanInput
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructOneLiner()
|
||||
{
|
||||
$fixture = '/** Short description and nothing more. */';
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEquals(
|
||||
'Short description and nothing more.',
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertCount(0, $object->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::__construct
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructFromReflector()
|
||||
{
|
||||
$object = new DocBlock(new \ReflectionClass($this));
|
||||
@@ -57,7 +111,7 @@ DOCBLOCK;
|
||||
$object->getShortDescription()
|
||||
);
|
||||
$this->assertEquals('', $object->getLongDescription()->getContents());
|
||||
$this->assertEquals(4, count($object->getTags()));
|
||||
$this->assertCount(4, $object->getTags());
|
||||
$this->assertTrue($object->hasTag('author'));
|
||||
$this->assertTrue($object->hasTag('copyright'));
|
||||
$this->assertTrue($object->hasTag('license'));
|
||||
@@ -67,10 +121,12 @@ DOCBLOCK;
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExceptionOnInvalidObject()
|
||||
{
|
||||
$object = new DocBlock($this);
|
||||
new DocBlock($this);
|
||||
}
|
||||
|
||||
public function testDotSeperation()
|
||||
@@ -93,6 +149,32 @@ DOCBLOCK;
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
* @expectedException \LogicException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInvalidTagBlock()
|
||||
{
|
||||
if (0 == ini_get('allow_url_include')) {
|
||||
$this->markTestSkipped('"data" URIs for includes are required.');
|
||||
}
|
||||
|
||||
require 'data:text/plain;base64,'. base64_encode(
|
||||
<<<DOCBLOCK_EXTENSION
|
||||
<?php
|
||||
class MyReflectionDocBlock extends \phpDocumentor\Reflection\DocBlock {
|
||||
protected function splitDocBlock(\$comment) {
|
||||
return array('', '', 'Invalid tag block');
|
||||
}
|
||||
}
|
||||
DOCBLOCK_EXTENSION
|
||||
);
|
||||
new \MyReflectionDocBlock('');
|
||||
|
||||
}
|
||||
|
||||
public function testTagCaseSensitivity()
|
||||
{
|
||||
$fixture = <<<DOCBLOCK
|
||||
@@ -115,7 +197,7 @@ DOCBLOCK;
|
||||
$object->getLongDescription()->getContents()
|
||||
);
|
||||
$tags = $object->getTags();
|
||||
$this->assertEquals(2, count($tags));
|
||||
$this->assertCount(2, $tags);
|
||||
$this->assertTrue($object->hasTag('method'));
|
||||
$this->assertTrue($object->hasTag('Method'));
|
||||
$this->assertInstanceOf(
|
||||
@@ -133,88 +215,74 @@ DOCBLOCK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether a type is expanded with the given namespace and that a
|
||||
* keyword is not expanded.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
||||
*
|
||||
* @depends testConstructFromReflector
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExpandTypeUsingNamespace()
|
||||
public function testGetTagsByNameZeroAndOneMatch()
|
||||
{
|
||||
$docblock = new DocBlock('', '\My\Namespace');
|
||||
$this->assertEquals('\My\Namespace\Mine', $docblock->expandType('Mine'));
|
||||
$object = new DocBlock(new \ReflectionClass($this));
|
||||
$this->assertEmpty($object->getTagsByName('category'));
|
||||
$this->assertCount(1, $object->getTagsByName('author'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether a type is expanded when no namespace is given.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
||||
*
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExpandTypeWithoutNamespace()
|
||||
public function testParseMultilineTag()
|
||||
{
|
||||
$docblock = new DocBlock('');
|
||||
$this->assertEquals('\Mine', $docblock->expandType('Mine'));
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* @return void Content on
|
||||
* multiple lines.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertCount(1, $object->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether a type is expanded with the given namespace when an alias
|
||||
* is provided.
|
||||
*
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::expandType()
|
||||
*
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::parseTags
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExpandTypeUsingNamespaceAlias()
|
||||
public function testParseMultilineTagWithLineBreaks()
|
||||
{
|
||||
$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')
|
||||
);
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* @return void Content on
|
||||
* multiple lines.
|
||||
*
|
||||
* One more, after the break.
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertCount(1, $object->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @depends testConstructWithTagsOnly
|
||||
* @covers \phpDocumentor\Reflection\DocBlock::getTagsByName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testThatExpandTypeDoesNotExpandAllKeywords($keyword)
|
||||
public function testGetTagsByNameMultipleMatch()
|
||||
{
|
||||
$docblock = new DocBlock('', '\My\Namespace');
|
||||
$this->assertSame($keyword, $docblock->expandType($keyword));
|
||||
}
|
||||
|
||||
public function getNonExpandableKeywordsForExpandType()
|
||||
{
|
||||
return array(
|
||||
array(null),
|
||||
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'),
|
||||
array('self'), array('$this'), array('callable')
|
||||
);
|
||||
$fixture = <<<DOCBLOCK
|
||||
/**
|
||||
* @param string
|
||||
* @param int
|
||||
* @return void
|
||||
*/
|
||||
DOCBLOCK;
|
||||
$object = new DocBlock($fixture);
|
||||
$this->assertEmpty($object->getTagsByName('category'));
|
||||
$this->assertCount(1, $object->getTagsByName('return'));
|
||||
$this->assertCount(2, $object->getTagsByName('param'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user