Skip to content

Commit

Permalink
Merge pull request #174 from rodrigoprimo/improve-test-coverage-arbit…
Browse files Browse the repository at this point in the history
…rary-parentheses-spacing

Generic/ArbitraryParenthesesSpacing: improve sniff code coverage
  • Loading branch information
jrfnl authored Dec 24, 2023
2 parents be32eca + afffe6c commit 9627bea
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,8 @@ class NonArbitraryParenthesesWithKeywords {
$d = new parent( $foo,$bar );
}
}

// Test that the match expression does not trigger the sniff.
$b = match ( $a ) {
1 => true,
};
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ class NonArbitraryParenthesesWithKeywords {
$d = new parent( $foo,$bar );
}
}

// Test that the match expression does not trigger the sniff.
$b = match ( $a ) {
1 => true,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

// Intentional parse error. Testing that the sniff is *not* triggered in this case.
function something $param ) {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,45 +26,53 @@ class ArbitraryParenthesesSpacingUnitTest extends AbstractSniffUnitTest
* The key of the array should represent the line number and the value
* should represent the number of errors that should occur on that line.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int>
*/
public function getErrorList()
public function getErrorList($testFile='')
{
return [
64 => 4,
66 => 1,
68 => 1,
69 => 1,
72 => 2,
73 => 2,
77 => 2,
81 => 4,
90 => 4,
94 => 1,
95 => 1,
97 => 1,
100 => 2,
101 => 2,
104 => 2,
107 => 2,
109 => 4,
111 => 4,
113 => 2,
115 => 2,
123 => 1,
125 => 2,
127 => 1,
131 => 1,
133 => 1,
137 => 1,
139 => 2,
141 => 1,
144 => 1,
146 => 1,
163 => 1,
164 => 1,
165 => 1,
];
switch ($testFile) {
case 'ArbitraryParenthesesSpacingUnitTest.1.inc':
return [
64 => 4,
66 => 1,
68 => 1,
69 => 1,
72 => 2,
73 => 2,
77 => 2,
81 => 4,
90 => 4,
94 => 1,
95 => 1,
97 => 1,
100 => 2,
101 => 2,
104 => 2,
107 => 2,
109 => 4,
111 => 4,
113 => 2,
115 => 2,
123 => 1,
125 => 2,
127 => 1,
131 => 1,
133 => 1,
137 => 1,
139 => 2,
141 => 1,
144 => 1,
146 => 1,
163 => 1,
164 => 1,
165 => 1,
];

default:
return [];
}//end switch

}//end getErrorList()

Expand All @@ -75,14 +83,22 @@ public function getErrorList()
* The key of the array should represent the line number and the value
* should represent the number of warnings that should occur on that line.
*
* @param string $testFile The name of the file being tested.
*
* @return array<int, int>
*/
public function getWarningList()
public function getWarningList($testFile='')
{
return [
55 => 1,
56 => 1,
];
switch ($testFile) {
case 'ArbitraryParenthesesSpacingUnitTest.1.inc':
return [
55 => 1,
56 => 1,
];

default:
return [];
}//end switch

}//end getWarningList()

Expand Down

0 comments on commit 9627bea

Please sign in to comment.