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 \Zend\Filter\FilterChain; |
||
16 | |||
17 | /** |
||
18 | * Tests the functionality for the Filter class. |
||
19 | */ |
||
20 | class FilterTest extends \Mockery\Adapter\Phpunit\MockeryTestCase |
||
21 | { |
||
22 | const FQCN = 'SomeFilterClass'; |
||
23 | |||
24 | /** @var ClassFactory|m\Mock */ |
||
25 | protected $classFactoryMock; |
||
26 | |||
27 | /** @var FilterChain|m\Mock */ |
||
28 | protected $filterChainMock; |
||
29 | |||
30 | /** @var Filter $fixture */ |
||
31 | protected $fixture; |
||
32 | |||
33 | /** |
||
34 | * Creates a new (empty) fixture object. |
||
35 | */ |
||
36 | protected function setUp() |
||
37 | { |
||
38 | $this->classFactoryMock = m::mock('phpDocumentor\Descriptor\Filter\ClassFactory'); |
||
39 | $this->filterChainMock = m::mock('Zend\Filter\FilterChain'); |
||
40 | $this->fixture = new Filter($this->classFactoryMock); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @covers phpDocumentor\Descriptor\Filter\Filter::__construct |
||
45 | */ |
||
46 | public function testClassFactoryIsSetUponConstruction() |
||
47 | { |
||
48 | $this->assertAttributeSame($this->classFactoryMock, 'factory', $this->fixture); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @covers phpDocumentor\Descriptor\Filter\Filter::attach |
||
53 | */ |
||
54 | public function testAttach() |
||
55 | { |
||
56 | $filterMock = m::mock('Zend\Filter\FilterInterface'); |
||
57 | |||
58 | $this->filterChainMock->shouldReceive('attach')->with($filterMock, FilterChain::DEFAULT_PRIORITY); |
||
0 ignored issues
–
show
|
|||
59 | $this->classFactoryMock->shouldReceive('getChainFor')->with(self::FQCN)->andReturn($this->filterChainMock); |
||
0 ignored issues
–
show
The method
shouldReceive does only exist in Mockery\Mock , but not in phpDocumentor\Descriptor\Filter\ClassFactory .
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...
|
|||
60 | |||
61 | $this->fixture->attach(self::FQCN, $filterMock); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @covers phpDocumentor\Descriptor\Filter\Filter::filter |
||
66 | */ |
||
67 | public function testFilter() |
||
68 | { |
||
69 | $filterableMock = m::mock('phpDocumentor\Descriptor\Filter\Filterable'); |
||
70 | |||
71 | $this->filterChainMock->shouldReceive('filter')->with($filterableMock)->andReturn($filterableMock); |
||
0 ignored issues
–
show
The method
shouldReceive does only exist in Mockery\Mock , but not in Zend\Filter\FilterChain .
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...
|
|||
72 | $this->classFactoryMock |
||
0 ignored issues
–
show
The method
shouldReceive does only exist in Mockery\Mock , but not in phpDocumentor\Descriptor\Filter\ClassFactory .
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...
|
|||
73 | ->shouldReceive('getChainFor')->with(get_class($filterableMock))->andReturn($this->filterChainMock); |
||
74 | |||
75 | $this->assertSame($filterableMock, $this->fixture->filter($filterableMock)); |
||
76 | } |
||
77 | } |
||
78 |
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: