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 StripOnVisibility class. |
19
|
|
|
*/ |
20
|
|
|
class StripOnVisibilityTest extends \Mockery\Adapter\Phpunit\MockeryTestCase |
21
|
|
|
{ |
22
|
|
|
/** @var ProjectDescriptorBuilder|m\Mock */ |
23
|
|
|
protected $builderMock; |
24
|
|
|
|
25
|
|
|
/** @var StripOnVisibility $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 StripOnVisibility($this->builderMock); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripOnVisibility::__construct |
39
|
|
|
*/ |
40
|
|
|
public function testProjectDescriptorBuilderIsSetUponConstruction() |
41
|
|
|
{ |
42
|
|
|
$this->assertAttributeSame($this->builderMock, 'builder', $this->fixture); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripOnVisibility::filter |
47
|
|
|
*/ |
48
|
|
|
public function testStripsTagFromDescriptionIfVisibilityIsNotAllowed() |
49
|
|
|
{ |
50
|
|
|
$this->builderMock->shouldReceive('isVisibilityAllowed')->andReturn(false); |
|
|
|
|
51
|
|
|
|
52
|
|
|
$descriptor = m::mock('phpDocumentor\Descriptor\Interfaces\VisibilityInterface'); |
53
|
|
|
$descriptor->shouldReceive('getVisibility'); |
54
|
|
|
|
55
|
|
|
$this->assertNull($this->fixture->filter($descriptor)); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripOnVisibility::filter |
60
|
|
|
*/ |
61
|
|
|
public function testKeepsDescriptorIfVisibilityIsAllowed() |
62
|
|
|
{ |
63
|
|
|
$this->builderMock->shouldReceive('isVisibilityAllowed')->andReturn(true); |
|
|
|
|
64
|
|
|
|
65
|
|
|
$descriptor = m::mock('phpDocumentor\Descriptor\Interfaces\VisibilityInterface'); |
66
|
|
|
$descriptor->shouldReceive('getVisibility'); |
67
|
|
|
|
68
|
|
|
$this->assertSame($descriptor, $this->fixture->filter($descriptor)); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripOnVisibility::filter |
73
|
|
|
*/ |
74
|
|
|
public function testKeepsDescriptorIfDescriptorNotInstanceOfVisibilityInterface() |
75
|
|
|
{ |
76
|
|
|
$this->builderMock->shouldReceive('isVisibilityAllowed')->andReturn(false); |
|
|
|
|
77
|
|
|
|
78
|
|
|
$descriptor = m::mock('\phpDocumentor\Descriptor\DescriptorAbstract'); |
79
|
|
|
|
80
|
|
|
$this->assertSame($descriptor, $this->fixture->filter($descriptor)); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
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: