From 9fed972cf968c401686640d7f0af6e436a8507f0 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Thu, 10 Oct 2024 22:56:50 +0200 Subject: [PATCH] phptests fixes --- includes/CLI/Plugin_Check_Command.php | 3 +- .../features/plugin-check-severity.feature | 33 +++---------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 98baaf7fd..4639be4b6 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -673,6 +673,7 @@ private function has_runtime_check( array $checks ) { * @param array $results Check results. * @param int $error_severity Error severity level. * @param int $warning_severity Warning severity level. + * @param bool $show_error_severity Show error severity as warning. * @return array Filtered results. */ private function get_filtered_results_by_severity( $results, $error_severity, $warning_severity, $show_error_severity = false ) { @@ -692,7 +693,7 @@ function ( $item ) use ( $error_severity ) { return ( 'ERROR' === $item['type'] && $item['severity'] < $error_severity ); } ); - + $errors_warning = array_map( function ( $item ) { $item['type'] = 'WARNING'; diff --git a/tests/behat/features/plugin-check-severity.feature b/tests/behat/features/plugin-check-severity.feature index 8a917fe5d..46b0efde2 100644 --- a/tests/behat/features/plugin-check-severity.feature +++ b/tests/behat/features/plugin-check-severity.feature @@ -123,9 +123,9 @@ Feature: Test that the severity level in plugin check works. """ obfuscated_code_detected,ERROR,6 """ - And STDOUT should contain: + And STDOUT should not contain: """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 + WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR,5 """ And STDOUT should contain: """ @@ -149,9 +149,9 @@ Feature: Test that the severity level in plugin check works. """ obfuscated_code_detected,ERROR,6 """ - And STDOUT should contain: + And STDOUT should not contain: """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 + WordPress.WP.AlternativeFunctions.rand_mt_rand,ERROR,5 """ And STDOUT should contain: """ @@ -193,27 +193,4 @@ Feature: Test that the severity level in plugin check works. """ When I run the WP-CLI command `plugin check foo-bar-wp --format=csv --fields=code,type,severity --severity=10` - Then STDOUT should contain: - """ - allow_unfiltered_uploads_detected,WARNING,7 - """ - And STDOUT should contain: - """ - obfuscated_code_detected,WARNING,6 - """ - And STDOUT should contain: - """ - WordPress.WP.AlternativeFunctions.rand_mt_rand,WARNING,5 - """ - And STDOUT should contain: - """ - outdated_tested_upto_header,WARNING,7 - """ - And STDOUT should not contain: - """ - default_readme_text,WARNING,7 - """ - And STDOUT should not contain: - """ - upgrade_notice_limit,WARNING,5 - """ + Then STDOUT should be empty \ No newline at end of file