DocBlockTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 20
c 2
b 0
f 0
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testDocBlockOnClassWithoutDocBlock() 0 6 1
A testDocBlock() 0 16 1
A testDocBlockFailOnNonExistentClass() 0 5 1
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
}