1 | <?php |
||
21 | abstract class VisiteeInterfaceTestCase extends TestCase |
||
22 | { |
||
23 | /** |
||
24 | * Test create. |
||
25 | */ |
||
26 | public function testCreate() |
||
35 | |||
36 | /** |
||
37 | * Test accept. |
||
38 | * |
||
39 | * @param VisitorInterface $visitorMock |
||
40 | * @param string $shouldVisitMethod |
||
41 | * @param string $acceptVisitorMethod |
||
|
|||
42 | * |
||
43 | * @dataProvider acceptVisitorDataProvider |
||
44 | */ |
||
45 | public function testAcceptVisitor($visitorMock, $shouldVisitMethod) |
||
46 | { |
||
47 | $this |
||
48 | ->given($visitorMock, $shouldVisitMethod) |
||
49 | ->calling($visitorMock) |
||
50 | ->methods( |
||
51 | function ($method) use ($shouldVisitMethod) { |
||
52 | return $method === \strtolower($shouldVisitMethod); |
||
53 | } |
||
54 | ) |
||
55 | ->return = 25 |
||
56 | ; |
||
57 | |||
58 | $this |
||
59 | /* @var \Cubiche\Core\Visitor\VisiteeInterface $visitee */ |
||
60 | ->given($visitee = $this->newDefaultTestedInstance()) |
||
61 | ->when($result = $visitee->accept($visitorMock)) |
||
62 | ->then() |
||
63 | ->mock($visitorMock) |
||
64 | ->call($shouldVisitMethod) |
||
65 | ->withArguments($visitee) |
||
66 | ->once() |
||
67 | ->integer($result) |
||
68 | ->isEqualTo(25) |
||
69 | ; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return string[][] |
||
74 | */ |
||
75 | protected function acceptVisitorDataProvider() |
||
76 | { |
||
77 | return array( |
||
78 | array($this->newMockVisitorInterface(), $this->shouldVisitMethod()), |
||
79 | array($this->newMockInstance(VisitorInterface::class), 'visit'), |
||
80 | ); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return string |
||
85 | */ |
||
86 | protected function visitorInterface() |
||
90 | |||
91 | /** |
||
92 | * @return string |
||
93 | */ |
||
94 | protected function shouldVisitMethod() |
||
98 | |||
99 | /** |
||
100 | * @return object |
||
101 | */ |
||
102 | protected function newMockVisitorInterface() |
||
106 | } |
||
107 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.