1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
<?php
/**
* @see https://github.com/laminas/laminas-code for the canonical source repository
* @copyright https://github.com/laminas/laminas-code/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-code/blob/master/LICENSE.md New BSD License
*/
namespace LaminasTest\Code\Reflection\DocBlock\Tag;
use Laminas\Code\Reflection\DocBlock\Tag\VarTag;
use PHPUnit\Framework\TestCase;
/**
* @group Laminas_Reflection
* @group Laminas_Reflection_DocBlock
*/
class VarTagTest extends TestCase
{
/**
* @dataProvider varTagProvider
*/
public function testParse(
string $line,
array $expectedTypes,
?string $expectedVariableName,
?string $expectedDescription
) {
$tag = new VarTag();
$tag->initialize($line);
$this->assertSame($expectedTypes, $tag->getTypes());
$this->assertSame($expectedVariableName, $tag->getVariableName());
$this->assertSame($expectedDescription, $tag->getDescription());
}
public function varTagProvider(): array
{
return [
'only type' => [
'string',
['string'],
null,
null,
],
'only multiple types' => [
'string|int',
['string', 'int'],
null,
null,
],
'type and name' => [
'string $test',
['string'],
'$test',
null,
],
'multiple types and name' => [
'string|int $test',
['string', 'int'],
'$test',
null,
],
'only name' => [
'$test',
[],
'$test',
null,
],
'name and description' => [
'$test Foo Bar',
[],
'$test',
'Foo Bar',
],
'type and description' => [
'string Foo bar',
['string'],
null,
'Foo bar',
],
'multiple types and description' => [
'string|int Foo bar',
['string', 'int'],
null,
'Foo bar',
],
'type, name and description' => [
'string $test Foo bar',
['string'],
'$test',
'Foo bar',
],
'multiple types, name and description' => [
'string|int $test Foo bar',
['string', 'int'],
'$test',
'Foo bar',
],
];
}
}
|