Passed
Push — master ( 1040d7...3fe017 )
by Phillip
01:23
created

DocBlockTest::testDocBlockOnClassWithoutDocBlock()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
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
}