1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MS\PHPMD\Tests\Functional\Symfony2; |
4
|
|
|
|
5
|
|
|
use MS\PHPMD\Tests\Functional\AbstractProcessTest; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class EntitySimpleGetterSetterTest |
9
|
|
|
* |
10
|
|
|
* @package MS\PHPMD\Tests\Functional\Symfony2 |
11
|
|
|
*/ |
12
|
|
|
class EntitySimpleGetterSetterTest extends AbstractProcessTest |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @covers MS\PHPMD\Rule\Symfony2\EntitySimpleGetterSetter |
16
|
|
|
* @covers MS\PHPMD\Rule\Symfony2\AbstractEntityRule |
17
|
|
|
*/ |
18
|
|
|
public function testEntitySimpleGetterSetterRule() |
19
|
|
|
{ |
20
|
|
|
$output = $this |
21
|
|
|
->runPhpmd('Entity/Foo.php', 'symfony2.xml') |
22
|
|
|
->getOutput(); |
23
|
|
|
|
24
|
|
|
$this->assertContains('Entity/Foo.php:80 The method should only be a simple get,set,is,has,add,remove in this entity.', $output); |
25
|
|
|
$this->assertContains('Entity/Foo.php:91 The method should only be a simple get,set,is,has,add,remove in this entity.', $output); |
26
|
|
|
$this->assertContains('Entity/Foo.php:101 The method should only be a simple get,set,is,has,add,remove in this entity.', $output); |
27
|
|
|
$this->assertContains('Entity/Foo.php:113 The method should only be a simple get,set,is,has,add,remove in this entity.', $output); |
28
|
|
|
|
29
|
|
|
$this->assertNotContains('Entity/Foo.php:22', $output); |
30
|
|
|
$this->assertNotContains('Entity/Foo.php:34', $output); |
31
|
|
|
$this->assertNotContains('Entity/Foo.php:46', $output); |
32
|
|
|
$this->assertNotContains('Entity/Foo.php:56', $output); |
33
|
|
|
$this->assertNotContains('Entity/Foo.php:68', $output); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @covers MS\PHPMD\Rule\Symfony2\EntitySimpleGetterSetter |
38
|
|
|
* @covers MS\PHPMD\Rule\Symfony2\AbstractEntityRule |
39
|
|
|
*/ |
40
|
|
|
public function testForceEntitySimpleGetterSetterRule() |
41
|
|
|
{ |
42
|
|
|
$output = $this |
43
|
|
|
->runPhpmd('Entity/FooAssociation.php', 'symfony2.xml') |
44
|
|
|
->getOutput(); |
45
|
|
|
|
46
|
|
|
$this->assertContains('Entity/FooAssociation.php:79 The method should only be a simple get,set,is,has,add,remove in this entity.', $output); |
47
|
|
|
$this->assertContains('Entity/FooAssociation.php:90 The method should only be a simple get,set,is,has,add,remove in this entity.', $output); |
48
|
|
|
$this->assertContains('Entity/FooAssociation.php:100 The method should only be a simple get,set,is,has,add,remove in this entity.', $output); |
49
|
|
|
$this->assertContains('Entity/FooAssociation.php:112 The method should only be a simple get,set,is,has,add,remove in this entity.', $output); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @covers MS\PHPMD\Rule\Symfony2\EntitySimpleGetterSetter |
54
|
|
|
* @covers MS\PHPMD\Rule\Symfony2\AbstractEntityRule |
55
|
|
|
*/ |
56
|
|
|
public function testRuleWithModel() |
57
|
|
|
{ |
58
|
|
|
$output = $this |
59
|
|
|
->runPhpmd('Model/Foo.php', 'symfony2.xml') |
60
|
|
|
->getOutput(); |
61
|
|
|
|
62
|
|
|
$this->assertEmpty(trim($output)); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @covers MS\PHPMD\Rule\Symfony2\EntitySimpleGetterSetter |
67
|
|
|
* @covers MS\PHPMD\Rule\Symfony2\AbstractEntityRule |
68
|
|
|
*/ |
69
|
|
|
public function testRuleWithTestForEntity() |
70
|
|
|
{ |
71
|
|
|
$output = $this |
72
|
|
|
->runPhpmd('Tests/Test.php', 'symfony2.xml') |
73
|
|
|
->getOutput(); |
74
|
|
|
|
75
|
|
|
$this->assertEmpty(trim($output)); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|