|
9 | 9 |
|
10 | 10 | namespace ZendTest\Code\Generator\DocBlock\Tag;
|
11 | 11 |
|
| 12 | +use PHPUnit\Framework\TestCase; |
12 | 13 | use Zend\Code\Generator\DocBlock\Tag\VarTag;
|
13 | 14 | use Zend\Code\Generator\DocBlock\TagManager;
|
| 15 | +use Zend\Code\Reflection\DocBlock\Tag\VarTag as ReflectionVarTag; |
14 | 16 | use Zend\Code\Reflection\DocBlockReflection;
|
15 | 17 |
|
16 | 18 | /**
|
17 |
| - * @group Zend_Code_Generator |
18 |
| - * @group Zend_Code_Generator_Php |
| 19 | + * @covers \Zend\Code\Generator\DocBlock\Tag\VarTag |
19 | 20 | */
|
20 |
| -class VarTagTest extends \PHPUnit_Framework_TestCase |
| 21 | +class VarTagTest extends TestCase |
21 | 22 | {
|
22 | 23 | /**
|
23 | 24 | * @var VarTag
|
24 | 25 | */
|
25 |
| - protected $tag; |
| 26 | + private $tag; |
| 27 | + |
26 | 28 | /**
|
27 | 29 | * @var TagManager
|
28 | 30 | */
|
29 |
| - protected $tagmanager; |
| 31 | + private $tagManager; |
30 | 32 |
|
31 |
| - public function setUp() |
| 33 | + protected function setUp() : void |
32 | 34 | {
|
33 |
| - $this->tag = new VarTag(); |
34 |
| - $this->tagmanager = new TagManager(); |
35 |
| - $this->tagmanager->initializeDefaultTags(); |
36 |
| - } |
| 35 | + parent::setUp(); |
37 | 36 |
|
38 |
| - public function tearDown() |
39 |
| - { |
40 |
| - $this->tag = null; |
41 |
| - $this->tagmanager = null; |
| 37 | + $this->tag = new VarTag(); |
| 38 | + $this->tagManager = new TagManager(); |
| 39 | + |
| 40 | + $this->tagManager->initializeDefaultTags(); |
42 | 41 | }
|
43 | 42 |
|
44 |
| - public function testGetterAndSetterPersistValue() |
| 43 | + public function testGetterAndSetterPersistValue() : void |
45 | 44 | {
|
46 |
| - $this->tag->setVariableName('variable'); |
47 |
| - $this->assertEquals('variable', $this->tag->getVariableName()); |
48 |
| - } |
| 45 | + $tag = new VarTag('variable'); |
49 | 46 |
|
| 47 | + self::assertSame('variable', $tag->getVariableName()); |
| 48 | + } |
50 | 49 |
|
51 |
| - public function testGetterForVariableNameTrimsCorrectly() |
| 50 | + public function testGetterForVariableNameTrimsCorrectly() : void |
52 | 51 | {
|
53 | 52 | $this->tag->setVariableName('$variable$');
|
54 | 53 | $this->assertEquals('variable$', $this->tag->getVariableName());
|
55 | 54 | }
|
56 | 55 |
|
57 |
| - public function testNameIsCorrect() |
| 56 | + public function testNameIsCorrect() : void |
58 | 57 | {
|
59 | 58 | $this->assertEquals('var', $this->tag->getName());
|
60 | 59 | }
|
61 | 60 |
|
62 |
| - public function testParamProducesCorrectDocBlockLine() |
| 61 | + public function testParamProducesCorrectDocBlockLine() : void |
63 | 62 | {
|
64 | 63 | $this->tag->setVariableName('variable');
|
65 | 64 | $this->tag->setTypes('string[]');
|
66 | 65 | $this->tag->setDescription('description');
|
67 | 66 | $this->assertEquals('@var string[] $variable description', $this->tag->generate());
|
68 | 67 | }
|
69 | 68 |
|
70 |
| - public function testConstructorWithOptions() |
| 69 | + public function testConstructorWithOptions() : void |
71 | 70 | {
|
72 | 71 | $this->tag->setOptions([
|
73 | 72 | 'variableName' => 'foo',
|
74 |
| - 'types' => ['string'], |
75 |
| - 'description' => 'description' |
| 73 | + 'types' => ['string'], |
| 74 | + 'description' => 'description', |
76 | 75 | ]);
|
77 | 76 | $tagWithOptionsFromConstructor = new VarTag('foo', ['string'], 'description');
|
78 | 77 | $this->assertEquals($this->tag->generate(), $tagWithOptionsFromConstructor->generate());
|
79 | 78 | }
|
80 | 79 |
|
81 |
| - public function testCreatingTagFromReflection() |
| 80 | + public function testCreatingTagFromReflection() : void |
82 | 81 | {
|
83 |
| - $docreflection = new DocBlockReflection('/** @var int $foo description'); |
84 |
| - $reflectionTag = $docreflection->getTag('var'); |
| 82 | + $reflectionTag = (new DocBlockReflection('/** @var int $foo description')) |
| 83 | + ->getTag('var'); |
| 84 | + |
| 85 | + self::assertInstanceOf(ReflectionVarTag::class, $reflectionTag); |
85 | 86 |
|
86 | 87 | /** @var VarTag $tag */
|
87 |
| - $tag = $this->tagmanager->createTagFromReflection($reflectionTag); |
88 |
| - $this->assertInstanceOf('Zend\Code\Generator\DocBlock\Tag\VarTag', $tag); |
| 88 | + $tag = $this->tagManager->createTagFromReflection($reflectionTag); |
| 89 | + |
| 90 | + $this->assertInstanceOf(VarTag::class, $tag); |
89 | 91 | $this->assertEquals('foo', $tag->getVariableName());
|
90 | 92 | $this->assertEquals('description', $tag->getDescription());
|
91 | 93 | $this->assertEquals('int', $tag->getTypesAsString());
|
|
0 commit comments