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\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); |
||
0 ignored issues
–
show
|
|||
52 | |||
53 | $descriptor = m::mock(MethodDescriptor::class); |
||
54 | $descriptor->shouldReceive('getVisibility')->andReturn('public'); |
||
0 ignored issues
–
show
The method
andReturn does only exist in Mockery\ExpectationInterface , but not in Mockery\HigherOrderMessage .
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...
|
|||
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); |
||
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...
|
|||
65 | |||
66 | $descriptor = m::mock(MethodDescriptor::class); |
||
67 | $descriptor->shouldReceive('getVisibility')->andReturn('public'); |
||
0 ignored issues
–
show
The method
andReturn does only exist in Mockery\ExpectationInterface , but not in Mockery\HigherOrderMessage .
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...
|
|||
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); |
||
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...
|
|||
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: