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 League\Pipeline\Pipeline; |
15
|
|
|
use \Mockery as m; |
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 FilterInterface|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(Pipeline::class); |
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(FilterInterface::class); |
57
|
|
|
|
58
|
|
|
$this->classFactoryMock->shouldReceive('attachTo')->with(self::FQCN, $filterMock); |
59
|
|
|
|
60
|
|
|
$this->fixture->attach(self::FQCN, $filterMock); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @covers phpDocumentor\Descriptor\Filter\Filter::filter |
65
|
|
|
*/ |
66
|
|
|
public function testFilter() |
67
|
|
|
{ |
68
|
|
|
$filterableMock = m::mock('phpDocumentor\Descriptor\Filter\Filterable'); |
69
|
|
|
|
70
|
|
|
$this->filterChainMock->shouldReceive('__invoke')->with($filterableMock)->andReturn($filterableMock); |
71
|
|
|
$this->classFactoryMock |
|
|
|
|
72
|
|
|
->shouldReceive('getChainFor')->with(get_class($filterableMock))->andReturn($this->filterChainMock); |
73
|
|
|
|
74
|
|
|
$this->assertSame($filterableMock, $this->fixture->filter($filterableMock)); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
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: