Trait_Test   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 96
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 6

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A tearDown() 0 4 1
A testGetFqsenAndGetName() 0 5 1
A testAddAndGettingProperties() 0 10 1
A testAddAndGettingMethods() 0 10 1
A testAddAndGettingUsedTrait() 0 10 1
A testGetDocblock() 0 4 1
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2018 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Reflection\Php;
14
15
use \Mockery as m;
16
use phpDocumentor\Reflection\DocBlock;
17
use phpDocumentor\Reflection\Fqsen;
18
use PHPUnit\Framework\TestCase;
19
20
/**
21
 * Tests the functionality for the Trait_ class.
22
 * @coversDefaultClass phpDocumentor\Reflection\Php\Trait_
23
 */
24
// @codingStandardsIgnoreStart
25
class Trait_Test extends TestCase
26
// @codingStandardsIgnoreEnd
27
{
28
    /** @var Trait_ $fixture */
29
    protected $fixture;
30
31
    /**
32
     * @var Fqsen
33
     */
34
    private $fqsen;
35
36
    /**
37
     * @var DocBlock
38
     */
39
    private $docBlock;
40
41
    /**
42
     * Creates a new (empty) fixture object.
43
     */
44
    protected function setUp()
45
    {
46
        $this->fqsen = new Fqsen('\MyTrait');
47
        $this->docBlock = new DocBlock('');
48
        $this->fixture = new Trait_($this->fqsen, $this->docBlock);
49
    }
50
51
    protected function tearDown()
52
    {
53
        m::close();
54
    }
55
56
    /**
57
     * @covers ::getFqsen
58
     * @covers ::getName
59
     * @covers ::__construct
60
     */
61
    public function testGetFqsenAndGetName()
62
    {
63
        $this->assertSame($this->fqsen, $this->fixture->getFqsen());
64
        $this->assertEquals($this->fqsen->getName(), $this->fixture->getName());
65
    }
66
67
    /**
68
     * @covers ::addProperty
69
     * @covers ::getProperties
70
     */
71
    public function testAddAndGettingProperties()
72
    {
73
        $this->assertEquals([], $this->fixture->getProperties());
74
75
        $property = new Property(new Fqsen('\MyTrait::$myProperty'));
76
77
        $this->fixture->addProperty($property);
78
79
        $this->assertEquals(['\MyTrait::$myProperty' => $property], $this->fixture->getProperties());
80
    }
81
82
    /**
83
     * @covers ::addMethod
84
     * @covers ::getMethods
85
     */
86
    public function testAddAndGettingMethods()
87
    {
88
        $this->assertEquals([], $this->fixture->getMethods());
89
90
        $method = new Method(new Fqsen('\MyTrait::myMethod()'));
91
92
        $this->fixture->addMethod($method);
93
94
        $this->assertEquals(['\MyTrait::myMethod()' => $method], $this->fixture->getMethods());
95
    }
96
97
    /**
98
     * @covers ::getUsedTraits
99
     * @covers ::AddUsedTrait
100
     */
101
    public function testAddAndGettingUsedTrait()
102
    {
103
        $this->assertEmpty($this->fixture->getUsedTraits());
104
105
        $trait = new Fqsen('\MyTrait');
106
107
        $this->fixture->addUsedTrait($trait);
108
109
        $this->assertSame(['\MyTrait' => $trait], $this->fixture->getUsedTraits());
110
    }
111
112
    /**
113
     * @covers ::__construct
114
     * @covers ::getDocBlock
115
     */
116
    public function testGetDocblock()
117
    {
118
        $this->assertSame($this->docBlock, $this->fixture->getDocBlock());
119
    }
120
}
121