@@ 13-48 (lines=36) @@ | ||
10 | * |
|
11 | * @package MS\PHPMD\Tests\Unit\CleanCode |
|
12 | */ |
|
13 | class InlineIfTest extends AbstractApplyTest |
|
14 | { |
|
15 | /** |
|
16 | * @covers MS\PHPMD\Rule\CleanCode\InlineIf |
|
17 | */ |
|
18 | public function testFindOneInlineIf() |
|
19 | { |
|
20 | $node = $this->getMethodNode('TestClass', 'doSomething', [ |
|
21 | 'ConditionalExpression' => [$this->getNode('?')] |
|
22 | ]); |
|
23 | ||
24 | $this->assertRule($node, 1); |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * @covers MS\PHPMD\Rule\CleanCode\InlineIf |
|
29 | */ |
|
30 | public function testFindNoInlineIf() |
|
31 | { |
|
32 | $node = $this->getMethodNode('TestClass', 'tryMore', [ |
|
33 | 'ConditionalExpression' => [] |
|
34 | ]); |
|
35 | ||
36 | $this->assertRule($node, 0); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * @return InlineIf |
|
41 | */ |
|
42 | protected function getRule() |
|
43 | { |
|
44 | $rule = new InlineIf(); |
|
45 | ||
46 | return $rule; |
|
47 | } |
|
48 | } |
|
49 |
@@ 13-48 (lines=36) @@ | ||
10 | * |
|
11 | * @package MS\PHPMD\Tests\Unit\CleanCode |
|
12 | */ |
|
13 | class SwitchStatementTest extends AbstractApplyTest |
|
14 | { |
|
15 | /** |
|
16 | * @covers MS\PHPMD\Rule\CleanCode\SwitchStatement |
|
17 | */ |
|
18 | public function testFindOneSwitchStatement() |
|
19 | { |
|
20 | $node = $this->getMethodNode('TestClass', 'doSomething', [ |
|
21 | 'SwitchStatement' => [$this->getNode('switch')] |
|
22 | ]); |
|
23 | ||
24 | $this->assertRule($node, 1); |
|
25 | } |
|
26 | ||
27 | /** |
|
28 | * @covers MS\PHPMD\Rule\CleanCode\SwitchStatement |
|
29 | */ |
|
30 | public function testFindNoSwitchStatement() |
|
31 | { |
|
32 | $node = $this->getMethodNode('TestClass', 'doSomething', [ |
|
33 | 'SwitchStatement' => [] |
|
34 | ]); |
|
35 | ||
36 | $this->assertRule($node, 0); |
|
37 | } |
|
38 | ||
39 | /** |
|
40 | * @return SwitchStatement |
|
41 | */ |
|
42 | protected function getRule() |
|
43 | { |
|
44 | $rule = new SwitchStatement(); |
|
45 | ||
46 | return $rule; |
|
47 | } |
|
48 | } |
|
49 |