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\MethodDescriptor; |
16
|
|
|
use phpDocumentor\Descriptor\ProjectDescriptorBuilder; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Tests the functionality for the StripOnVisibility class. |
20
|
|
|
*/ |
21
|
|
|
class StripOnVisibilityTest extends \Mockery\Adapter\Phpunit\MockeryTestCase |
22
|
|
|
{ |
23
|
|
|
/** @var ProjectDescriptorBuilder|m\Mock */ |
24
|
|
|
protected $builderMock; |
25
|
|
|
|
26
|
|
|
/** @var StripOnVisibility $fixture */ |
27
|
|
|
protected $fixture; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Creates a new (empty) fixture object. |
31
|
|
|
*/ |
32
|
|
|
protected function setUp() |
33
|
|
|
{ |
34
|
|
|
$this->builderMock = m::mock('phpDocumentor\Descriptor\ProjectDescriptorBuilder'); |
35
|
|
|
$this->fixture = new StripOnVisibility($this->builderMock); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripOnVisibility::__construct |
40
|
|
|
*/ |
41
|
|
|
public function testProjectDescriptorBuilderIsSetUponConstruction() |
42
|
|
|
{ |
43
|
|
|
$this->assertAttributeSame($this->builderMock, 'builder', $this->fixture); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripOnVisibility::__invoke |
48
|
|
|
*/ |
49
|
|
|
public function testStripsTagFromDescriptionIfVisibilityIsNotAllowed() |
50
|
|
|
{ |
51
|
|
|
$this->builderMock->shouldReceive('getProjectDescriptor->isVisibilityAllowed')->andReturn(false); |
|
|
|
|
52
|
|
|
|
53
|
|
|
$descriptor = m::mock(MethodDescriptor::class); |
54
|
|
|
$descriptor->shouldReceive('getVisibility')->andReturn('public'); |
|
|
|
|
55
|
|
|
|
56
|
|
|
$this->assertNull($this->fixture->__invoke($descriptor)); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripOnVisibility::__invoke |
61
|
|
|
*/ |
62
|
|
|
public function testKeepsDescriptorIfVisibilityIsAllowed() |
63
|
|
|
{ |
64
|
|
|
$this->builderMock->shouldReceive('getProjectDescriptor->isVisibilityAllowed')->andReturn(true); |
|
|
|
|
65
|
|
|
|
66
|
|
|
$descriptor = m::mock(MethodDescriptor::class); |
67
|
|
|
$descriptor->shouldReceive('getVisibility')->andReturn('public'); |
|
|
|
|
68
|
|
|
|
69
|
|
|
$this->assertSame($descriptor, $this->fixture->__invoke($descriptor)); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @covers phpDocumentor\Descriptor\Filter\StripOnVisibility::__invoke |
74
|
|
|
*/ |
75
|
|
|
public function testKeepsDescriptorIfDescriptorNotInstanceOfVisibilityInterface() |
76
|
|
|
{ |
77
|
|
|
$this->builderMock->shouldReceive('getProjectDescriptor->isVisibilityAllowed')->andReturn(false); |
|
|
|
|
78
|
|
|
|
79
|
|
|
$descriptor = m::mock('\phpDocumentor\Descriptor\DescriptorAbstract'); |
80
|
|
|
|
81
|
|
|
$this->assertSame($descriptor, $this->fixture->__invoke($descriptor)); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
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: