1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* phpDocumentor |
4
|
|
|
* |
5
|
|
|
* PHP Version 5.3 |
6
|
|
|
* |
7
|
|
|
* @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com) |
8
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
9
|
|
|
* @link http://phpdoc.org |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace phpDocumentor\Descriptor\Filter; |
13
|
|
|
|
14
|
|
|
use \Mockery as m; |
15
|
|
|
use phpDocumentor\Descriptor\ProjectDescriptorBuilder; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Tests the functionality for the StripInternal class. |
19
|
|
|
*/ |
20
|
|
|
class StripInternalTest extends \Mockery\Adapter\Phpunit\MockeryTestCase |
21
|
|
|
{ |
22
|
|
|
/** @var ProjectDescriptorBuilder|m\Mock */ |
23
|
|
|
protected $builderMock; |
24
|
|
|
|
25
|
|
|
/** @var StripInternal $fixture */ |
26
|
|
|
protected $fixture; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Creates a new (empty) fixture object. |
30
|
|
|
*/ |
31
|
|
|
protected function setUp() |
32
|
|
|
{ |
33
|
|
|
$this->builderMock = m::mock('phpDocumentor\Descriptor\ProjectDescriptorBuilder'); |
34
|
|
|
$this->fixture = new StripInternal($this->builderMock); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripInternal::__construct |
39
|
|
|
*/ |
40
|
|
|
public function testProjectDescriptorBuilderIsSetUponConstruction() |
41
|
|
|
{ |
42
|
|
|
$this->assertAttributeSame($this->builderMock, 'builder', $this->fixture); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripInternal::filter |
47
|
|
|
*/ |
48
|
|
|
public function testStripsInternalTagFromDescription() |
49
|
|
|
{ |
50
|
|
|
$this->builderMock->shouldReceive('isVisibilityAllowed')->andReturn(false); |
|
|
|
|
51
|
|
|
$descriptor = m::mock('phpDocumentor\Descriptor\DescriptorAbstract'); |
52
|
|
|
$descriptor->shouldReceive('getTags->get')->with('internal')->andReturn(null); |
53
|
|
|
|
54
|
|
|
$descriptor->shouldReceive('getDescription')->andReturn('without {@internal blabla }}internal tag'); |
|
|
|
|
55
|
|
|
$descriptor->shouldReceive('setDescription')->with('without internal tag'); |
56
|
|
|
|
57
|
|
|
$this->assertSame($descriptor, $this->fixture->filter($descriptor)); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripInternal::filter |
62
|
|
|
*/ |
63
|
|
|
public function testStripsInternalTagFromDescriptionIfTagDescriptionContainsBraces() |
64
|
|
|
{ |
65
|
|
|
$this->builderMock->shouldReceive('isVisibilityAllowed')->andReturn(false); |
|
|
|
|
66
|
|
|
$descriptor = m::mock('phpDocumentor\Descriptor\DescriptorAbstract'); |
67
|
|
|
$descriptor->shouldReceive('getTags->get')->with('internal')->andReturn(null); |
68
|
|
|
|
69
|
|
|
$descriptor->shouldReceive('getDescription')->andReturn('without {@internal bla{bla} }}internal tag'); |
|
|
|
|
70
|
|
|
$descriptor->shouldReceive('setDescription')->with('without internal tag'); |
71
|
|
|
|
72
|
|
|
$this->assertSame($descriptor, $this->fixture->filter($descriptor)); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripInternal::filter |
77
|
|
|
*/ |
78
|
|
|
public function testResolvesInternalTagFromDescriptionIfParsePrivateIsTrue() |
79
|
|
|
{ |
80
|
|
|
$this->builderMock->shouldReceive('isVisibilityAllowed')->andReturn(true); |
|
|
|
|
81
|
|
|
$descriptor = m::mock('phpDocumentor\Descriptor\DescriptorAbstract'); |
82
|
|
|
|
83
|
|
|
$descriptor->shouldReceive('getDescription')->andReturn('without {@internal blabla }}internal tag'); |
|
|
|
|
84
|
|
|
$descriptor->shouldReceive('setDescription')->with('without blabla internal tag'); |
85
|
|
|
|
86
|
|
|
$this->assertSame($descriptor, $this->fixture->filter($descriptor)); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripInternal::filter |
91
|
|
|
*/ |
92
|
|
|
public function testRemovesDescriptorIfTaggedAsInternal() |
93
|
|
|
{ |
94
|
|
|
$this->builderMock->shouldReceive('isVisibilityAllowed')->andReturn(false); |
|
|
|
|
95
|
|
|
|
96
|
|
|
$descriptor = m::mock('phpDocumentor\Descriptor\DescriptorAbstract'); |
97
|
|
|
$descriptor->shouldReceive('getDescription'); |
98
|
|
|
$descriptor->shouldReceive('setDescription'); |
99
|
|
|
$descriptor->shouldReceive('getTags->get')->with('internal')->andReturn(true); |
100
|
|
|
|
101
|
|
|
$this->assertNull($this->fixture->filter($descriptor)); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripInternal::filter |
106
|
|
|
*/ |
107
|
|
|
public function testKeepsDescriptorIfTaggedAsInternalAndParsePrivateIsTrue() |
108
|
|
|
{ |
109
|
|
|
$this->builderMock->shouldReceive('isVisibilityAllowed')->andReturn(true); |
|
|
|
|
110
|
|
|
|
111
|
|
|
$descriptor = m::mock('phpDocumentor\Descriptor\DescriptorAbstract'); |
112
|
|
|
$descriptor->shouldReceive('getDescription'); |
113
|
|
|
$descriptor->shouldReceive('setDescription'); |
114
|
|
|
$descriptor->shouldReceive('getTags->get')->with('internal')->andReturn(true); |
115
|
|
|
|
116
|
|
|
$this->assertSame($descriptor, $this->fixture->filter($descriptor)); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripInternal::filter |
121
|
|
|
*/ |
122
|
|
|
public function testDescriptorIsUnmodifiedIfThereIsNoInternalTag() |
123
|
|
|
{ |
124
|
|
|
$this->builderMock->shouldReceive('isVisibilityAllowed')->andReturn(true); |
|
|
|
|
125
|
|
|
|
126
|
|
|
$descriptor = m::mock('phpDocumentor\Descriptor\DescriptorAbstract'); |
127
|
|
|
$descriptor->shouldReceive('getDescription'); |
128
|
|
|
$descriptor->shouldReceive('setDescription'); |
129
|
|
|
$descriptor->shouldReceive('getTags->get')->with('internal')->andReturn(false); |
130
|
|
|
|
131
|
|
|
$this->assertEquals($descriptor, $this->fixture->filter($descriptor)); |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: