1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Deployee\Components\DocBlock; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
use Deployee\Components\DocBlock\Test\TestClass; |
8
|
|
|
use Deployee\Components\DocBlock\Test\TestClassWithouDocBlock; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
|
11
|
|
|
class DocBlockTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
public function testDocBlock() |
14
|
|
|
{ |
15
|
|
|
$docBlock = new DocBlock(); |
16
|
|
|
$allTags = $docBlock->getTags(TestClass::class); |
17
|
|
|
$barTags = $docBlock->getTagsByName(TestClass::class, 'bar'); |
18
|
|
|
$hasAwesomeTag = $docBlock->hasTag(TestClass::class, 'awesome'); |
19
|
|
|
|
20
|
|
|
$this->assertSame([ |
21
|
|
|
'foo' => [], |
22
|
|
|
'bar' => ['one', 'two', 'three'], |
23
|
|
|
'awesome' => ['yes'] |
24
|
|
|
], $allTags); |
25
|
|
|
|
26
|
|
|
$this->assertSame(['one', 'two', 'three'], $barTags); |
27
|
|
|
$this->assertTrue($hasAwesomeTag); |
28
|
|
|
$this->assertFalse($docBlock->hasTag(TestClass::class, 'doesNotExist')); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testDocBlockFailOnNonExistentClass() |
32
|
|
|
{ |
33
|
|
|
$docBlock = new DocBlock(); |
34
|
|
|
$this->expectException(\ReflectionException::class); |
35
|
|
|
$docBlock->getTags('SomeClassThatDoesNotExist'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testDocBlockOnClassWithoutDocBlock() |
39
|
|
|
{ |
40
|
|
|
$docBlock = new DocBlock(); |
41
|
|
|
$this->assertSame([], $docBlock->getTagsByName(TestClassWithouDocBlock::class, 'bar')); |
42
|
|
|
$this->assertSame([], $docBlock->getTags(TestClassWithouDocBlock::class)); |
43
|
|
|
$this->assertFalse($docBlock->hasTag(TestClassWithouDocBlock::class, 'awesome')); |
44
|
|
|
} |
45
|
|
|
} |