mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Parse template tag for generics (#21)
* Parse template tag for generics * Fixed templatetag docblock * Fixed PHP 7 issue * Fixed PHP 7.2 issue * Fixed another 7.2 issue
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* phpDocumentor Template 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 Barryvdh\Reflection\DocBlock\Tag;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test class for \Barryvdh\Reflection\DocBlock\Tag\TemplateTag
|
||||
*
|
||||
* @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 TemplateTagTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
|
||||
* for the @see doc block.
|
||||
*
|
||||
* @param string $type
|
||||
* @param string $content
|
||||
* @param string $exContent
|
||||
* @param string $exReference
|
||||
*
|
||||
* @covers \Barryvdh\Reflection\DocBlock\Tag\SeeTag
|
||||
* @dataProvider provideDataForConstuctor
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testConstructorParesInputsIntoCorrectFields(
|
||||
$type,
|
||||
$content,
|
||||
$exContent,
|
||||
$exDescription,
|
||||
$exTemplateName,
|
||||
$exBound
|
||||
) {
|
||||
$tag = new TemplateTag($type, $content);
|
||||
|
||||
$this->assertEquals($type, $tag->getName());
|
||||
$this->assertEquals($exContent, $tag->getContent());
|
||||
$this->assertEquals($exDescription, $tag->getDescription());
|
||||
$this->assertEquals($exTemplateName, $tag->getTemplateName());
|
||||
$this->assertEquals($exBound, $tag->getBound());
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testConstructorParesInputsIntoCorrectFields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provideDataForConstuctor()
|
||||
{
|
||||
// $type, $content, $exContent, $exDescription, $exTemplateName, $exBound
|
||||
return array(
|
||||
array(
|
||||
'template',
|
||||
'TValue',
|
||||
'TValue',
|
||||
'',
|
||||
'TValue',
|
||||
null,
|
||||
),
|
||||
array(
|
||||
'template',
|
||||
'TValue of string',
|
||||
'TValue of string',
|
||||
'',
|
||||
'TValue',
|
||||
'string',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -144,6 +144,27 @@ class CollectionTest extends TestCase
|
||||
$this->assertSame($expected, $collection->getArrayCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fixture
|
||||
* @param array $expected
|
||||
*
|
||||
* @dataProvider provideTypesToExpandWithGenerics
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddWithGenerics($fixture, $expected)
|
||||
{
|
||||
$collection = new Collection(
|
||||
array(),
|
||||
new Context('\My\Space', array('Alias' => '\My\Space\Aliasing')),
|
||||
array('TValue')
|
||||
);
|
||||
$collection->add($fixture);
|
||||
|
||||
$this->assertSame($expected, $collection->getArrayCopy());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
|
||||
*
|
||||
@@ -267,4 +288,22 @@ class CollectionTest extends TestCase
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the types and their expected values to test the retrieval of
|
||||
* types including generics.
|
||||
*
|
||||
* @param string $method Name of the method consuming this data provider.
|
||||
* @param string $namespace Name of the namespace to user as basis.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function provideTypesToExpandWithGenerics($method, $namespace = '\My\Space\\')
|
||||
{
|
||||
return array(
|
||||
array('TValue', array('TValue')),
|
||||
array('TValue[]', array('TValue[]')),
|
||||
array('TValue|DocBlock', array('TValue', $namespace . 'DocBlock')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user