From 33e14221403f218c53dad5cd475c27e584e702b5 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 26 Dec 2023 12:22:25 +0545 Subject: [PATCH] Update check behat tests --- tests/behat/features/plugin-check.feature | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/behat/features/plugin-check.feature b/tests/behat/features/plugin-check.feature index 693660fe2..4eea080c2 100644 --- a/tests/behat/features/plugin-check.feature +++ b/tests/behat/features/plugin-check.feature @@ -29,3 +29,48 @@ Feature: Test that the WP-CLI command works. """ All output should be run through an escaping function """ + + When I run `wp plugin check hello.php --format=csv` + Then STDOUT should contain: + """ + line,column,type,code,message + 49,31,ERROR,WordPress.WP.AlternativeFunctions.rand_mt_rand,"mt_rand() is discouraged. Use the far less predictable wp_rand() instead." + """ + + When I run `wp plugin check hello.php --format=json` + Then STDOUT should contain: + """ + {"line":49,"column":31,"type":"ERROR","code":"WordPress.WP.AlternativeFunctions.rand_mt_rand","message":"mt_rand() is discouraged. Use the far less predictable wp_rand() instead."} + """ + + When I run `wp plugin check hello.php --ignore-errors` + Then STDOUT should be empty + + When I run `wp plugin check hello.php --checks=plugin_review_phpcs` + Then STDOUT should contain: + """ + WordPress.WP.AlternativeFunctions.rand_mt_rand + """ + And STDOUT should not contain: + """ + WordPress.Security.EscapeOutput.OutputNotEscaped + """ + + When I run `wp plugin check hello.php --exclude-checks=late_escaping` + Then STDOUT should not contain: + """ + WordPress.Security.EscapeOutput.OutputNotEscaped + """ + And STDOUT should contain: + """ + WordPress.WP.AlternativeFunctions.rand_mt_rand + """ + When I run `wp plugin check hello.php --categories=security` + Then STDOUT should contain: + """ + WordPress.Security.EscapeOutput.OutputNotEscaped + """ + And STDOUT should not contain: + """ + WordPress.WP.AlternativeFunctions.rand_mt_rand + """