From 4aed540d928aae6030042142b57636ebfddd0268 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 21 Jul 2020 23:39:21 +0200 Subject: [PATCH] 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. --- tests/RulesetTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/RulesetTest.php b/tests/RulesetTest.php index 0272ca5b..bf21dd7c 100644 --- a/tests/RulesetTest.php +++ b/tests/RulesetTest.php @@ -230,6 +230,10 @@ private function check_missing_expected_values() { } foreach ( $lines as $line_number => $expected_count_of_type_violations ) { + if ( 0 === $expected_count_of_type_violations ) { + continue; + } + if ( ! isset( $this->{$type}[ $line_number ] ) ) { $this->error_warning_message( $expected_count_of_type_violations, $type, 0, $line_number ); } elseif ( $this->{$type}[ $line_number ] !== $expected_count_of_type_violations ) { @@ -247,6 +251,10 @@ private function check_missing_expected_values() { private function check_unexpected_values() { foreach ( [ 'errors', 'warnings' ] as $type ) { foreach ( $this->$type as $line_number => $actual_count_of_type_violations ) { + if ( 0 === $actual_count_of_type_violations ) { + continue; + } + if ( ! isset( $this->expected[ $type ][ $line_number ] ) ) { $this->error_warning_message( 0, $type, $actual_count_of_type_violations, $line_number ); } elseif ( $actual_count_of_type_violations !== $this->expected[ $type ][ $line_number ] ) {