|
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 phpDocumentor\Reflection\DocBlock; |
|
16
|
|
|
use phpDocumentor\Reflection\Fqsen; |
|
17
|
|
|
use PHPUnit\Framework\TestCase; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Tests the functionality for the Namespace_ class. |
|
21
|
|
|
* |
|
22
|
|
|
* @coversDefaultClass phpDocumentor\Reflection\Php\Namespace_ |
|
23
|
|
|
*/ |
|
24
|
|
|
// @codingStandardsIgnoreStart |
|
25
|
|
|
class Namespace_Test extends TestCase |
|
26
|
|
|
// @codingStandardsIgnoreEnd |
|
27
|
|
|
{ |
|
28
|
|
|
/** @var Namespace_ $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 (emoty) fixture object. |
|
43
|
|
|
*/ |
|
44
|
|
|
protected function setUp() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->fqsen = new Fqsen('\MySpace'); |
|
47
|
|
|
$this->docBlock = new DocBlock(''); |
|
48
|
|
|
|
|
49
|
|
|
$this->fixture = new Namespace_($this->fqsen, $this->docBlock); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @covers ::__construct |
|
54
|
|
|
* @covers ::getClasses |
|
55
|
|
|
* @covers ::AddClass |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testAddAndGetClasses() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->assertEmpty($this->fixture->getClasses()); |
|
60
|
|
|
|
|
61
|
|
|
$class = new Fqsen('\MySpace\MyClass'); |
|
62
|
|
|
$this->fixture->addClass($class); |
|
63
|
|
|
|
|
64
|
|
|
$this->assertEquals(['\MySpace\MyClass' => $class], $this->fixture->getClasses()); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @covers ::__construct |
|
69
|
|
|
* @covers ::getConstants |
|
70
|
|
|
* @covers ::addConstant |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testAddAndGetConstants() |
|
73
|
|
|
{ |
|
74
|
|
|
$this->assertEmpty($this->fixture->getConstants()); |
|
75
|
|
|
|
|
76
|
|
|
$constant = new Fqsen('\MySpace::MY_CONSTANT'); |
|
77
|
|
|
$this->fixture->addConstant($constant); |
|
78
|
|
|
|
|
79
|
|
|
$this->assertEquals(['\MySpace::MY_CONSTANT' => $constant], $this->fixture->getConstants()); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @covers ::__construct |
|
84
|
|
|
* @covers ::getFunctions |
|
85
|
|
|
* @covers ::addFunction |
|
86
|
|
|
*/ |
|
87
|
|
|
public function testAddAndGetFunctions() |
|
88
|
|
|
{ |
|
89
|
|
|
$this->assertEmpty($this->fixture->getFunctions()); |
|
90
|
|
|
|
|
91
|
|
|
$function = new Fqsen('\MySpace\MyFunction()'); |
|
92
|
|
|
$this->fixture->addFunction($function); |
|
93
|
|
|
|
|
94
|
|
|
$this->assertEquals(['\MySpace\MyFunction()' => $function], $this->fixture->getFunctions()); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @covers ::__construct |
|
99
|
|
|
* @covers ::getInterfaces |
|
100
|
|
|
* @covers ::addInterface |
|
101
|
|
|
*/ |
|
102
|
|
|
public function testAddAndGetInterfaces() |
|
103
|
|
|
{ |
|
104
|
|
|
$this->assertEmpty($this->fixture->getInterfaces()); |
|
105
|
|
|
|
|
106
|
|
|
$interface = new Fqsen('\MySpace\MyInterface'); |
|
107
|
|
|
$this->fixture->addInterface($interface); |
|
108
|
|
|
|
|
109
|
|
|
$this->assertEquals(['\MySpace\MyInterface' => $interface], $this->fixture->getInterfaces()); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* @covers ::__construct |
|
114
|
|
|
* @covers ::getTraits |
|
115
|
|
|
* @covers ::addTrait |
|
116
|
|
|
*/ |
|
117
|
|
|
public function testAddAndGetTraits() |
|
118
|
|
|
{ |
|
119
|
|
|
$this->assertEmpty($this->fixture->getTraits()); |
|
120
|
|
|
|
|
121
|
|
|
$trait = new Fqsen('\MySpace\MyTrait'); |
|
122
|
|
|
$this->fixture->addTrait($trait); |
|
123
|
|
|
|
|
124
|
|
|
$this->assertEquals(['\MySpace\MyTrait' => $trait], $this->fixture->getTraits()); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* @covers ::__construct |
|
129
|
|
|
* @covers ::getFqsen |
|
130
|
|
|
* @covers ::getName |
|
131
|
|
|
*/ |
|
132
|
|
|
public function testGetFqsen() |
|
133
|
|
|
{ |
|
134
|
|
|
$this->assertSame($this->fqsen, $this->fixture->getFqsen()); |
|
135
|
|
|
$this->assertEquals($this->fqsen->getName(), $this->fixture->getName()); |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|