1 | <?php |
||
13 | class ControllerMethodNameTest extends AbstractApplyTest |
||
14 | { |
||
15 | /** |
||
16 | * @covers MS\PHPMD\Rule\Symfony2\ControllerMethodName |
||
17 | */ |
||
18 | public function testApplyNoConcreteClass() |
||
25 | |||
26 | /** |
||
27 | * @covers MS\PHPMD\Rule\Symfony2\ControllerMethodName |
||
28 | */ |
||
29 | public function testApplyNoController() |
||
37 | |||
38 | /** |
||
39 | * @covers MS\PHPMD\Rule\Symfony2\ControllerMethodName |
||
40 | */ |
||
41 | public function testApplyWithDirtyController() |
||
42 | { |
||
43 | $className = 'TestController'; |
||
44 | $validMethodName = 'testAction'; |
||
45 | $notValidMethodName = 'doSomething'; |
||
46 | |||
47 | $validMethodNode = \Mockery::mock('PHPMD\Node\MethodNode'); |
||
48 | $validMethodNode->shouldReceive('getImage')->andReturn($validMethodName); |
||
49 | $validMethodNode->shouldReceive('getParentName')->andReturn($className); |
||
50 | $validMethodNode->shouldReceive('getName')->andReturn($validMethodName); |
||
51 | |||
52 | $notValidMethodNode = \Mockery::mock('PHPMD\Node\MethodNode'); |
||
53 | $notValidMethodNode->shouldReceive('getImage')->andReturn($notValidMethodName); |
||
54 | $notValidMethodNode->shouldReceive('getParentName')->andReturn($className); |
||
55 | $notValidMethodNode->shouldReceive('getName')->andReturn($notValidMethodName); |
||
56 | |||
57 | $classNode = \Mockery::mock('PHPMD\Node\ClassNode'); |
||
58 | $classNode->shouldReceive('isAbstract')->andReturn(false); |
||
59 | $classNode->shouldReceive('getImage')->andReturn($className); |
||
60 | $classNode->shouldReceive('getMethods')->andReturn([$validMethodNode, $notValidMethodNode]); |
||
61 | |||
62 | $this->assertRule($classNode, 1); |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return ControllerMethodName |
||
67 | */ |
||
68 | protected function getRule() |
||
76 | } |
||
77 |