@return now trims the content before splitting it;

Removed ThrowTag.php (unnecessary, given the map, which aliases "throw" to ThrowsTag.php);
Added tests for ThrowsTag, along with a few other minor test additions and fixes;
This commit is contained in:
Vasil Rangelov
2012-11-11 19:51:04 +02:00
parent 2348c16485
commit 6602ce0375
7 changed files with 187 additions and 56 deletions
@@ -68,22 +68,52 @@ class ParamTagTest extends \PHPUnit_Framework_TestCase
array('param', 'int', 'int', array('int'), '', ''),
array('param', '$bob', '', array(), '$bob', ''),
array(
'param', 'int Number of bobs', 'int', array('int'), '',
'param',
'int Number of bobs',
'int',
array('int'),
'',
'Number of bobs'
),
array('param', 'int $bob', 'int', array('int'), '$bob', ''),
array(
'param', 'int $bob Number of bobs', 'int', 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 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',
"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"
array(
'param',
"\nint \$bob Type on a new line",
'int',
array('int'),
'$bob',
"Type on a new line"
)
);
}
@@ -26,14 +26,15 @@ 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\ParamTag::getType
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ParamTag::getTypes
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::getType
* @covers \phpDocumentor\Reflection\DocBlock\Tag\ReturnTag::getTypes
*
* @dataProvider provideDataForConstructor
*
@@ -71,6 +72,27 @@ class ReturnTagTest extends \PHPUnit_Framework_TestCase
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"
)
);
}
}
@@ -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"
)
);
}
}
@@ -31,7 +31,7 @@ class UsesTagTest extends \PHPUnit_Framework_TestCase
* @param string $exContent
* @param string $exReference
*
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tag\UsesTag
* @dataProvider provideDataForConstuctor
*
* @return void