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

Class_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 phpDocumentor\Reflection\Location;
19
use PHPUnit\Framework\TestCase;
20
21
/**
22
 * Tests the functionality for the Class_ class.
23
 * @coversDefaultClass phpDocumentor\Reflection\Php\Class_
24
 */
25
// @codingStandardsIgnoreStart
26
class Class_Test extends TestCase
27
// @codingStandardsIgnoreEnd
28
{
29
    /**
30
     * @var Class_
31
     */
32
    private $fixture;
33
34
    /**
35
     * @var Fqsen
36
     */
37
    private $parent;
38
39
    /**
40
     * @var Fqsen
41
     */
42
    private $fqsen;
43
44
    /**
45
     * @var DocBlock
46
     */
47
    private $docBlock;
48
    /**
49
     * Creates a new (emoty) fixture object.
50
     */
51
    protected function setUp()
52
    {
53
        $this->parent = new Fqsen('\MyParentClass');
54
        $this->fqsen = new Fqsen('\MyClass');
55
        $this->docBlock = new DocBlock('');
56
57
        $this->fixture = new Class_($this->fqsen, $this->docBlock, null, false, false, new Location(1));
58
    }
59
60
    protected function tearDown()
61
    {
62
        m::close();
63
    }
64
65
    /**
66
     * @covers ::getParent
67
     * @covers ::__construct
68
     */
69
    public function testGettingParent()
70
    {
71
        $class = new Class_($this->fqsen, $this->docBlock, null, false, false, null);
72
        $this->assertNull($class->getParent());
73
74
        $class = new Class_($this->fqsen, $this->docBlock, $this->parent, false, false, null);
75
        $this->assertSame($this->parent, $class->getParent());
76
    }
77
78
    /**
79
     * @covers ::getInterfaces
80
     * @covers ::AddInterface
81
     */
82
    public function testAddAndGettingInterfaces()
83
    {
84
        $this->assertEmpty($this->fixture->getInterfaces());
85
86
        $interface = new Fqsen('\MyInterface');
87
88
        $this->fixture->addInterface($interface);
89
90
        $this->assertSame(array('\MyInterface' => $interface), $this->fixture->getInterfaces());
91
    }
92
93
    /**
94
     * @covers ::getConstants
95
     * @covers ::addConstant
96
     */
97
    public function testAddAndGettingConstants()
98
    {
99
        $this->assertEmpty($this->fixture->getConstants());
100
101
        $constant = new Constant(new Fqsen('\MyClass::MY_CONSTANT'));
102
103
        $this->fixture->addConstant($constant);
104
105
        $this->assertSame(array('\MyClass::MY_CONSTANT' => $constant), $this->fixture->getConstants());
106
    }
107
108
    /**
109
     * @covers ::addProperty
110
     * @covers ::getProperties
111
     */
112
    public function testAddAndGettingProperties()
113
    {
114
        $this->assertEmpty($this->fixture->getProperties());
115
116
        $property = new Property(new Fqsen('\MyClass::$myProperty'));
117
118
        $this->fixture->addProperty($property);
119
120
        $this->assertSame(array('\MyClass::$myProperty' => $property), $this->fixture->getProperties());
121
    }
122
123
    /**
124
     * @covers ::addMethod
125
     * @covers ::getMethods
126
     */
127
    public function testAddAndGettingMethods()
128
    {
129
        $this->assertEmpty($this->fixture->getMethods());
130
131
        $method = new Method(new Fqsen('\MyClass::myMethod()'));
132
133
        $this->fixture->addMethod($method);
134
135
        $this->assertSame(array('\MyClass::myMethod()' => $method), $this->fixture->getMethods());
136
    }
137
138
    /**
139
     * @covers ::getUsedTraits
140
     * @covers ::AddUsedTrait
141
     */
142
    public function testAddAndGettingUsedTrait()
143
    {
144
        $this->assertEmpty($this->fixture->getUsedTraits());
145
146
        $trait = new Fqsen('\MyTrait');
147
148
        $this->fixture->addUsedTrait($trait);
149
150
        $this->assertSame(array('\MyTrait' => $trait), $this->fixture->getUsedTraits());
151
    }
152
153
    /**
154
     * @covers ::isAbstract
155
     * @covers ::__construct
156
     */
157
    public function testGettingWhetherClassIsAbstract()
158
    {
159
        $class = new Class_($this->fqsen, $this->docBlock, null, false, false);
160
        $this->assertFalse($class->isAbstract());
161
162
        $class = new Class_($this->fqsen, $this->docBlock, null, true, false);
163
        $this->assertTrue($class->isAbstract());
164
    }
165
166
    /**
167
     * @covers ::isFinal
168
     * @covers ::__construct
169
     */
170
    public function testGettingWhetherClassIsFinal()
171
    {
172
        $class = new Class_($this->fqsen, $this->docBlock, null, false, false);
173
        $this->assertFalse($class->isFinal());
174
175
        $class = new Class_($this->fqsen, $this->docBlock, null, false, true);
176
        $this->assertTrue($class->isFinal());
177
    }
178
}
179