Skip to content

Commit 0c6c929

Browse files
authored
Merge pull request #497 from rodrigoprimo/test-coverage-function-call-argument-spacing
Generic/FunctionCallArgumentSpacing: improve code coverage
2 parents 870843b + e9b9777 commit 0c6c929

File tree

4 files changed

+59
-33
lines changed

4 files changed

+59
-33
lines changed

src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc renamed to src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,8 @@ $foo = new MyClass(
172172
$obj,
173173
'getMethod',
174174
);
175+
176+
#[AttributeName(1, 2)]
177+
#[AttributeName(1,2)]
178+
179+
$callable = myCallable(...);

src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed renamed to src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.1.inc.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,8 @@ $foo = new MyClass(
172172
$obj,
173173
'getMethod',
174174
);
175+
176+
#[AttributeName(1, 2)]
177+
#[AttributeName(1, 2)]
178+
179+
$callable = myCallable(...);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// Intentional parse error (missing closing parenthesis).
4+
// This should be the only test in this file.
5+
// Testing that the sniff is *not* triggered.
6+
7+
myFunction(

src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,51 @@ final class FunctionCallArgumentSpacingUnitTest extends AbstractSniffUnitTest
2626
* The key of the array should represent the line number and the value
2727
* should represent the number of errors that should occur on that line.
2828
*
29+
* @param string $testFile The name of the test file to process.
30+
*
2931
* @return array<int, int>
3032
*/
31-
public function getErrorList()
33+
public function getErrorList($testFile='')
3234
{
33-
return [
34-
5 => 1,
35-
6 => 1,
36-
7 => 2,
37-
8 => 1,
38-
11 => 1,
39-
12 => 1,
40-
13 => 1,
41-
42 => 3,
42-
43 => 3,
43-
45 => 1,
44-
46 => 2,
45-
79 => 1,
46-
82 => 1,
47-
93 => 1,
48-
105 => 1,
49-
107 => 1,
50-
108 => 2,
51-
114 => 1,
52-
115 => 1,
53-
119 => 1,
54-
125 => 2,
55-
130 => 2,
56-
131 => 1,
57-
132 => 2,
58-
133 => 2,
59-
134 => 1,
60-
154 => 2,
61-
155 => 1,
62-
162 => 2,
63-
170 => 1,
64-
];
35+
switch ($testFile) {
36+
case 'FunctionCallArgumentSpacingUnitTest.1.inc':
37+
return [
38+
5 => 1,
39+
6 => 1,
40+
7 => 2,
41+
8 => 1,
42+
11 => 1,
43+
12 => 1,
44+
13 => 1,
45+
42 => 3,
46+
43 => 3,
47+
45 => 1,
48+
46 => 2,
49+
79 => 1,
50+
82 => 1,
51+
93 => 1,
52+
105 => 1,
53+
107 => 1,
54+
108 => 2,
55+
114 => 1,
56+
115 => 1,
57+
119 => 1,
58+
125 => 2,
59+
130 => 2,
60+
131 => 1,
61+
132 => 2,
62+
133 => 2,
63+
134 => 1,
64+
154 => 2,
65+
155 => 1,
66+
162 => 2,
67+
170 => 1,
68+
177 => 1,
69+
];
70+
71+
default:
72+
return [];
73+
}//end switch
6574

6675
}//end getErrorList()
6776

0 commit comments

Comments
 (0)