@@ 47-53 (lines=7) @@ | ||
44 | * |
|
45 | * @return void |
|
46 | */ |
|
47 | public function testRuleNotAppliesToLocalVariableInFunctionWithNameSmallerThanThreshold() |
|
48 | { |
|
49 | $rule = new LongVariable(); |
|
50 | $rule->addProperty('maximum', 6); |
|
51 | $rule->setReport($this->getReportWithNoViolation()); |
|
52 | $rule->apply($this->getFunction()); |
|
53 | } |
|
54 | ||
55 | /** |
|
56 | * testRuleNotAppliesToLocalVariableInFunctionWithNameEqualToThreshold |
|
@@ 60-66 (lines=7) @@ | ||
57 | * |
|
58 | * @return void |
|
59 | */ |
|
60 | public function testRuleNotAppliesToLocalVariableInFunctionWithNameEqualToThreshold() |
|
61 | { |
|
62 | $rule = new LongVariable(); |
|
63 | $rule->addProperty('maximum', 6); |
|
64 | $rule->setReport($this->getReportWithNoViolation()); |
|
65 | $rule->apply($this->getFunction()); |
|
66 | } |
|
67 | ||
68 | /** |
|
69 | * testRuleAppliesToFunctionParameterWithNameLongerThanThreshold |
|
@@ 86-92 (lines=7) @@ | ||
83 | * |
|
84 | * @return void |
|
85 | */ |
|
86 | public function testRuleNotAppliesToFunctionParameterWithNameSmallerThanThreshold() |
|
87 | { |
|
88 | $rule = new LongVariable(); |
|
89 | $rule->addProperty('maximum', 17); |
|
90 | $rule->setReport($this->getReportWithNoViolation()); |
|
91 | $rule->apply($this->getFunction()); |
|
92 | } |
|
93 | ||
94 | /** |
|
95 | * testRuleAppliesToLocalVariableInMethodWithNameLongerThanThreshold |
@@ 34-41 (lines=8) @@ | ||
31 | * |
|
32 | * @return void |
|
33 | */ |
|
34 | public function testRuleAppliesToFunctionWithNameShorterThanThreshold() |
|
35 | { |
|
36 | $rule = new ShortMethodName(); |
|
37 | $rule->addProperty('minimum', 54); |
|
38 | $rule->addProperty('exceptions', ''); |
|
39 | $rule->setReport($this->getReportWithOneViolation()); |
|
40 | $rule->apply($this->getFunction()); |
|
41 | } |
|
42 | ||
43 | /** |
|
44 | * testRuleNotAppliesToFunctionWithNameEqualToThreshold |
|
@@ 48-55 (lines=8) @@ | ||
45 | * |
|
46 | * @return void |
|
47 | */ |
|
48 | public function testRuleNotAppliesToFunctionWithNameEqualToThreshold() |
|
49 | { |
|
50 | $rule = new ShortMethodName(); |
|
51 | $rule->addProperty('minimum', 52); |
|
52 | $rule->addProperty('exceptions', ''); |
|
53 | $rule->setReport($this->getReportWithNoViolation()); |
|
54 | $rule->apply($this->getFunction()); |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * testRuleNotAppliesToFunctionWithNameLongerThanThreshold |
|
@@ 62-69 (lines=8) @@ | ||
59 | * |
|
60 | * @return void |
|
61 | */ |
|
62 | public function testRuleNotAppliesToFunctionWithNameLongerThanThreshold() |
|
63 | { |
|
64 | $rule = new ShortMethodName(); |
|
65 | $rule->addProperty('minimum', 54); |
|
66 | $rule->addProperty('exceptions', ''); |
|
67 | $rule->setReport($this->getReportWithNoViolation()); |
|
68 | $rule->apply($this->getFunction()); |
|
69 | } |
|
70 | ||
71 | /** |
|
72 | * testRuleAppliesToFunctionWithNameShorterThanThreshold |
|
@@ 90-97 (lines=8) @@ | ||
87 | * |
|
88 | * @return void |
|
89 | */ |
|
90 | public function testRuleNotAppliesToMethodWithNameEqualToThreshold() |
|
91 | { |
|
92 | $rule = new ShortMethodName(); |
|
93 | $rule->addProperty('minimum', 50); |
|
94 | $rule->addProperty('exceptions', ''); |
|
95 | $rule->setReport($this->getReportWithNoViolation()); |
|
96 | $rule->apply($this->getMethod()); |
|
97 | } |
|
98 | ||
99 | /** |
|
100 | * testRuleNotAppliesToMethodWithNameLongerThanThreshold |
|
@@ 104-111 (lines=8) @@ | ||
101 | * |
|
102 | * @return void |
|
103 | */ |
|
104 | public function testRuleNotAppliesToMethodWithNameLongerThanThreshold() |
|
105 | { |
|
106 | $rule = new ShortMethodName(); |
|
107 | $rule->addProperty('minimum', 52); |
|
108 | $rule->addProperty('exceptions', ''); |
|
109 | $rule->setReport($this->getReportWithNoViolation()); |
|
110 | $rule->apply($this->getMethod()); |
|
111 | } |
|
112 | ||
113 | /** |
|
114 | * testRuleNotAppliesToMethodWithNameLongerThanThreshold |
|
@@ 118-125 (lines=8) @@ | ||
115 | * |
|
116 | * @return void |
|
117 | */ |
|
118 | public function testRuleNotAppliesToMethodWithShortNameWhenException() |
|
119 | { |
|
120 | $rule = new ShortMethodName(); |
|
121 | $rule->addProperty('minimum', 100); |
|
122 | $rule->addProperty('exceptions', 'testRuleNotAppliesToMethodWithShortNameWhenException,another'); |
|
123 | $rule->setReport($this->getReportWithNoViolation()); |
|
124 | $rule->apply($this->getMethod()); |
|
125 | } |
|
126 | ||
127 | /** |
|
128 | * testRuleAlsoWorksWithoutExceptionListConfigured |
|
@@ 135-141 (lines=7) @@ | ||
132 | * @link https://github.com/phpmd/phpmd/issues/80 |
|
133 | * @link https://github.com/phpmd/phpmd/issues/270 |
|
134 | */ |
|
135 | public function testRuleAlsoWorksWithoutExceptionListConfigured() |
|
136 | { |
|
137 | $rule = new ShortMethodName(); |
|
138 | $rule->addProperty('minimum', 100); |
|
139 | $rule->setReport($this->getReportWithNoViolation()); |
|
140 | $rule->apply($this->getMethodMock()); |
|
141 | } |
|
142 | } |
|
143 |
@@ 49-56 (lines=8) @@ | ||
46 | * |
|
47 | * @return void |
|
48 | */ |
|
49 | public function testRuleNotAppliesToTryCatchBlocksInsideForeach() |
|
50 | { |
|
51 | $rule = new ShortVariable(); |
|
52 | $rule->addProperty('minimum', 3); |
|
53 | $rule->addProperty('exceptions', ''); |
|
54 | $rule->setReport($this->getReportWithNoViolation()); |
|
55 | $rule->apply($this->getFunction()); |
|
56 | } |
|
57 | ||
58 | /** |
|
59 | * testRuleNotAppliesToLocalVariableInFunctionWithNameLongerThanThreshold |
|
@@ 63-70 (lines=8) @@ | ||
60 | * |
|
61 | * @return void |
|
62 | */ |
|
63 | public function testRuleNotAppliesToLocalVariableInFunctionWithNameLongerThanThreshold() |
|
64 | { |
|
65 | $rule = new ShortVariable(); |
|
66 | $rule->addProperty('minimum', 2); |
|
67 | $rule->addProperty('exceptions', ''); |
|
68 | $rule->setReport($this->getReportWithNoViolation()); |
|
69 | $rule->apply($this->getFunction()); |
|
70 | } |
|
71 | ||
72 | /** |
|
73 | * testRuleNotAppliesToLocalVariableInFunctionWithNameEqualToThreshold |
|
@@ 77-84 (lines=8) @@ | ||
74 | * |
|
75 | * @return void |
|
76 | */ |
|
77 | public function testRuleNotAppliesToLocalVariableInFunctionWithNameEqualToThreshold() |
|
78 | { |
|
79 | $rule = new ShortVariable(); |
|
80 | $rule->addProperty('minimum', 3); |
|
81 | $rule->addProperty('exceptions', ''); |
|
82 | $rule->setReport($this->getReportWithNoViolation()); |
|
83 | $rule->apply($this->getFunction()); |
|
84 | } |
|
85 | ||
86 | /** |
|
87 | * testRuleAppliesToFunctionParameterWithNameShorterThanThreshold |
|
@@ 105-112 (lines=8) @@ | ||
102 | * |
|
103 | * @return void |
|
104 | */ |
|
105 | public function testRuleNotAppliesToFunctionParameterWithNameLongerThanThreshold() |
|
106 | { |
|
107 | $rule = new ShortVariable(); |
|
108 | $rule->addProperty('minimum', 3); |
|
109 | $rule->addProperty('exceptions', ''); |
|
110 | $rule->setReport($this->getReportWithNoViolation()); |
|
111 | $rule->apply($this->getFunction()); |
|
112 | } |
|
113 | ||
114 | /** |
|
115 | * testRuleAppliesToLocalVariableInMethodWithNameShorterThanThreshold |
|
@@ 263-270 (lines=8) @@ | ||
260 | * |
|
261 | * @return void |
|
262 | */ |
|
263 | public function testRuleNotAppliesToShortVariableNameAsForLoopIndex() |
|
264 | { |
|
265 | $rule = new ShortVariable(); |
|
266 | $rule->addProperty('minimum', 3); |
|
267 | $rule->addProperty('exceptions', ''); |
|
268 | $rule->setReport($this->getReportWithNoViolation()); |
|
269 | $rule->apply($this->getFunction()); |
|
270 | } |
|
271 | ||
272 | /** |
|
273 | * testRuleNotAppliesToShortVariableNameAsForeachLoopIndex |
|
@@ 277-284 (lines=8) @@ | ||
274 | * |
|
275 | * @return void |
|
276 | */ |
|
277 | public function testRuleNotAppliesToShortVariableNameAsForeachLoopIndex() |
|
278 | { |
|
279 | $rule = new ShortVariable(); |
|
280 | $rule->addProperty('minimum', 3); |
|
281 | $rule->addProperty('exceptions', ''); |
|
282 | $rule->setReport($this->getReportWithNoViolation()); |
|
283 | $rule->apply($this->getFunction()); |
|
284 | } |
|
285 | ||
286 | /** |
|
287 | * testRuleNotAppliesToShortVariableNameInCatchStatement |
|
@@ 291-298 (lines=8) @@ | ||
288 | * |
|
289 | * @return void |
|
290 | */ |
|
291 | public function testRuleNotAppliesToShortVariableNameInCatchStatement() |
|
292 | { |
|
293 | $rule = new ShortVariable(); |
|
294 | $rule->addProperty('minimum', 3); |
|
295 | $rule->addProperty('exceptions', ''); |
|
296 | $rule->setReport($this->getReportWithNoViolation()); |
|
297 | $rule->apply($this->getFunction()); |
|
298 | } |
|
299 | ||
300 | /** |
|
301 | * testRuleNotAppliesToStaticMembersAccessedInMethod |
@@ 434-440 (lines=7) @@ | ||
431 | * |
|
432 | * @return void |
|
433 | */ |
|
434 | public function testRuleDoesNotApplyToUnusedLocalVariableInFunction() |
|
435 | { |
|
436 | $rule = new UnusedLocalVariable(); |
|
437 | $rule->addProperty('allow-unused-foreach-variables', 'false'); |
|
438 | $rule->setReport($this->getReportWithNoViolation()); |
|
439 | $rule->apply($this->getFunction()); |
|
440 | } |
|
441 | ||
442 | /** |
|
443 | * testRuleDoesNotApplyToUnusedLocalVariableInMethod |