These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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); |
||
0 ignored issues
–
show
|
|||
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); |
||
0 ignored issues
–
show
The method
shouldReceive does only exist in Mockery\Mock , but not in phpDocumentor\Descriptor\ProjectDescriptorBuilder .
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: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
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); |
||
0 ignored issues
–
show
The method
shouldReceive does only exist in Mockery\Mock , but not in phpDocumentor\Descriptor\ProjectDescriptorBuilder .
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: class A
{
public function foo() { }
}
class B extends A
{
public function bar() { }
}
/**
* @param A|B $x
*/
function someFunction($x)
{
$x->foo(); // This call is fine as the method exists in A and B.
$x->bar(); // This method only exists in B and might cause an error.
}
Available Fixes
Loading history...
|
|||
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: