Skip to content

Commit 63a8cbe

Browse files
authored
Merge pull request #488 from rodrigoprimo/test-coverage-space-after-cast
Generic/SpaceAfterCast: improve code coverage
2 parents c336428 + 16ca507 commit 63a8cbe

File tree

4 files changed

+65
-41
lines changed

4 files changed

+65
-41
lines changed

src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc renamed to src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.1.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,8 @@ $var = (int)
9393
$var1 + (bool) $var2;
9494
// phpcs:set Generic.Formatting.SpaceAfterCast ignoreNewlines false
9595
// phpcs:set Generic.Formatting.SpaceAfterCast spacing 1
96+
97+
$var = (boolean)/* comment */ $var2;
98+
99+
$var = ( int )$spacesInsideParenthesis;
100+
$var = ( int )$tabsInsideParenthesis;

src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.inc.fixed renamed to src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.1.inc.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,8 @@ $var = (int)
9090
$var1 + (bool)$var2;
9191
// phpcs:set Generic.Formatting.SpaceAfterCast ignoreNewlines false
9292
// phpcs:set Generic.Formatting.SpaceAfterCast spacing 1
93+
94+
$var = (boolean)/* comment */ $var2;
95+
96+
$var = ( int ) $spacesInsideParenthesis;
97+
$var = ( int ) $tabsInsideParenthesis;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$var = (int)

src/Standards/Generic/Tests/Formatting/SpaceAfterCastUnitTest.php

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,50 +26,61 @@ final class SpaceAfterCastUnitTest 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 run.
30+
*
2931
* @return array<int, int>
3032
*/
31-
public function getErrorList()
33+
public function getErrorList($testFile='')
3234
{
33-
return [
34-
4 => 1,
35-
5 => 1,
36-
8 => 1,
37-
9 => 1,
38-
12 => 1,
39-
13 => 1,
40-
16 => 1,
41-
17 => 1,
42-
20 => 1,
43-
21 => 1,
44-
24 => 1,
45-
25 => 1,
46-
28 => 1,
47-
29 => 1,
48-
32 => 1,
49-
33 => 1,
50-
36 => 1,
51-
37 => 1,
52-
40 => 1,
53-
41 => 1,
54-
44 => 1,
55-
45 => 1,
56-
51 => 1,
57-
53 => 1,
58-
55 => 1,
59-
58 => 1,
60-
64 => 1,
61-
72 => 1,
62-
73 => 1,
63-
75 => 1,
64-
76 => 1,
65-
78 => 1,
66-
82 => 1,
67-
84 => 1,
68-
85 => 1,
69-
86 => 1,
70-
88 => 1,
71-
93 => 1,
72-
];
35+
switch ($testFile) {
36+
case 'SpaceAfterCastUnitTest.1.inc':
37+
return [
38+
4 => 1,
39+
5 => 1,
40+
8 => 1,
41+
9 => 1,
42+
12 => 1,
43+
13 => 1,
44+
16 => 1,
45+
17 => 1,
46+
20 => 1,
47+
21 => 1,
48+
24 => 1,
49+
25 => 1,
50+
28 => 1,
51+
29 => 1,
52+
32 => 1,
53+
33 => 1,
54+
36 => 1,
55+
37 => 1,
56+
40 => 1,
57+
41 => 1,
58+
44 => 1,
59+
45 => 1,
60+
51 => 1,
61+
53 => 1,
62+
55 => 1,
63+
58 => 1,
64+
64 => 1,
65+
72 => 1,
66+
73 => 1,
67+
75 => 1,
68+
76 => 1,
69+
78 => 1,
70+
82 => 1,
71+
84 => 1,
72+
85 => 1,
73+
86 => 1,
74+
88 => 1,
75+
93 => 1,
76+
97 => 1,
77+
99 => 1,
78+
100 => 1,
79+
];
80+
81+
default:
82+
return [];
83+
}//end switch
7384

7485
}//end getErrorList()
7586

0 commit comments

Comments
 (0)