Completed
Push — develop ( 28aa0b...3fae3c )
by Jaap
13s
created

Trait_Test::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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-2015 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
52
    protected function tearDown()
53
    {
54
        m::close();
55
    }
56
57
    /**
58
     * @covers ::getFqsen
59
     * @covers ::getName
60
     * @covers ::__construct
61
     */
62
    public function testGetFqsenAndGetName()
63
    {
64
        $this->assertSame($this->fqsen, $this->fixture->getFqsen());
65
        $this->assertEquals($this->fqsen->getName(), $this->fixture->getName());
66
    }
67
68
    /**
69
     * @covers ::addProperty
70
     * @covers ::getProperties
71
     */
72
    public function testAddAndGettingProperties()
73
    {
74
        $this->assertEquals(array(), $this->fixture->getProperties());
75
76
        $property = new Property(new Fqsen('\MyTrait::$myProperty'));
77
78
        $this->fixture->addProperty($property);
79
80
        $this->assertEquals(array('\MyTrait::$myProperty' => $property), $this->fixture->getProperties());
81
    }
82
83
    /**
84
     * @covers ::addMethod
85
     * @covers ::getMethods
86
     */
87
    public function testAddAndGettingMethods()
88
    {
89
        $this->assertEquals(array(), $this->fixture->getMethods());
90
91
        $method = new Method(new Fqsen('\MyTrait::myMethod()'));
92
93
        $this->fixture->addMethod($method);
94
95
        $this->assertEquals(array('\MyTrait::myMethod()' => $method), $this->fixture->getMethods());
96
    }
97
98
    /**
99
     * @covers ::getUsedTraits
100
     * @covers ::AddUsedTrait
101
     */
102
    public function testAddAndGettingUsedTrait()
103
    {
104
        $this->assertEmpty($this->fixture->getUsedTraits());
105
106
        $trait = new Fqsen('\MyTrait');
107
108
        $this->fixture->addUsedTrait($trait);
109
110
        $this->assertSame(array('\MyTrait' => $trait), $this->fixture->getUsedTraits());
111
    }
112
113
    /**
114
     * @covers ::__construct
115
     * @covers ::getDocBlock
116
     */
117
    public function testGetDocblock()
118
    {
119
        $this->assertSame($this->docBlock, $this->fixture->getDocBlock());
120
    }
121
}
122