Skip to content

Commit 4aed540

Browse files
committed
RulesetTest: fix the test script to be able to handle 0 values
Turns out the test script was not set up to be able to deal with `0` values and would throw a very informative "_Expected 0 errors, found 0 on line 7._" error in such a case. Fixed now.
1 parent 1a421d4 commit 4aed540

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/RulesetTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ private function check_missing_expected_values() {
230230
}
231231

232232
foreach ( $lines as $line_number => $expected_count_of_type_violations ) {
233+
if ( 0 === $expected_count_of_type_violations ) {
234+
continue;
235+
}
236+
233237
if ( ! isset( $this->{$type}[ $line_number ] ) ) {
234238
$this->error_warning_message( $expected_count_of_type_violations, $type, 0, $line_number );
235239
} elseif ( $this->{$type}[ $line_number ] !== $expected_count_of_type_violations ) {
@@ -247,6 +251,10 @@ private function check_missing_expected_values() {
247251
private function check_unexpected_values() {
248252
foreach ( [ 'errors', 'warnings' ] as $type ) {
249253
foreach ( $this->$type as $line_number => $actual_count_of_type_violations ) {
254+
if ( 0 === $actual_count_of_type_violations ) {
255+
continue;
256+
}
257+
250258
if ( ! isset( $this->expected[ $type ][ $line_number ] ) ) {
251259
$this->error_warning_message( 0, $type, $actual_count_of_type_violations, $line_number );
252260
} elseif ( $actual_count_of_type_violations !== $this->expected[ $type ][ $line_number ] ) {

0 commit comments

Comments
 (0)