From 1579c401c30c09ceb17be5708d4c4d1ed9e4ddca Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sat, 25 Apr 2020 02:10:21 +0100 Subject: [PATCH 1/5] Promote a non-200 response from the cron spawn test to an error rather than a warning. --- src/Cron_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cron_Command.php b/src/Cron_Command.php index 127186e71..2bb4cf022 100644 --- a/src/Cron_Command.php +++ b/src/Cron_Command.php @@ -50,7 +50,7 @@ public function test() { if ( 200 === $code ) { WP_CLI::success( 'WP-Cron spawning is working as expected.' ); } else { - WP_CLI::warning( sprintf( 'WP-Cron spawn succeeded but returned HTTP status code: %1$s %2$s', $code, $message ) ); + WP_CLI::error( sprintf( 'WP-Cron spawn returned HTTP status code: %1$s %2$s', $code, $message ) ); } } From dfa341ede846e9fa5d79155e5efeebd67ac90284 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sat, 25 Apr 2020 02:10:42 +0100 Subject: [PATCH 2/5] Remove the feature test for the cron spawn test because it sends a request to `example.com` --- features/cron.feature | 7 ------- 1 file changed, 7 deletions(-) diff --git a/features/cron.feature b/features/cron.feature index 0652d1ea2..9ec1e9fd7 100644 --- a/features/cron.feature +++ b/features/cron.feature @@ -189,13 +189,6 @@ Feature: Manage WP-Cron events and schedules | name | interval | | hourly | 3600 | - Scenario: Testing WP-Cron - When I try `wp cron test` - Then STDERR should not contain: - """ - Error: - """ - Scenario: Run multiple cron events When I try `wp cron event run` Then STDERR should be: From 5191037f43d5eeb0a1fe81d89da2edaf8ce967b5 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Fri, 21 Jan 2022 16:11:00 -0600 Subject: [PATCH 3/5] Allow Composer plugins to run --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9cd4b9784..6f3611e1d 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,10 @@ }, "config": { "process-timeout": 7200, - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "extra": { "branch-alias": { From d9f1f04b175fac54a046667b70f63764b245f8e2 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Fri, 21 Jan 2022 16:25:47 -0600 Subject: [PATCH 4/5] Adapt anchor text --- features/cron.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/cron.feature b/features/cron.feature index 9ec1e9fd7..e514b08d3 100644 --- a/features/cron.feature +++ b/features/cron.feature @@ -2,7 +2,7 @@ Feature: Manage WP-Cron events and schedules Background: Given a WP install - And I run `wp config set DISABLE_WP_CRON false --raw --type=constant --anchor='// ** MySQL settings - You can get this info from your web host ** //'` + And I run `wp config set DISABLE_WP_CRON false --raw --type=constant --anchor="if ( ! defined( 'DISABLE_WP_CRON' ) )"` Scenario: Scheduling and then deleting an event When I run `wp cron event schedule wp_cli_test_event_1 '+1 hour 5 minutes' --0=banana` From 6a34611c928adeec141d062f4fac0757f4da8f9c Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Fri, 21 Jan 2022 17:59:47 -0600 Subject: [PATCH 5/5] Add cron testing --- composer.json | 1 + features/cron.feature | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/composer.json b/composer.json index 6f3611e1d..6ffa2270c 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ }, "require-dev": { "wp-cli/entity-command": "^1.3 || ^2", + "wp-cli/server-command": "^2.0", "wp-cli/wp-cli-tests": "^3.1" }, "config": { diff --git a/features/cron.feature b/features/cron.feature index e514b08d3..e605bcfdd 100644 --- a/features/cron.feature +++ b/features/cron.feature @@ -189,6 +189,40 @@ Feature: Manage WP-Cron events and schedules | name | interval | | hourly | 3600 | + Scenario: Testing WP-Cron + Given a php.ini file: + """ + error_log = {RUN_DIR}/server.log + log_errors = on + """ + And I launch in the background `wp server --host=localhost --port=8080 --config=php.ini` + And a wp-content/mu-plugins/set_cron_site_url.php file: + """ +