From 247052d722bb34f2dc0ebc27f0dfe7a97ea85f5d Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Fri, 30 Oct 2026 20:44:00 +0100 Subject: [PATCH 1/2] Test wp-cli/wp-cli-tests#400 Co-Authored-By: Claude Opus 5.5 --- composer.json | 2 +- features/transient-patch.feature | 36 ++++++---- features/transient-pluck.feature | 12 ++-- features/transient.feature | 120 ++++++++++++++++++------------- 4 files changed, 102 insertions(+), 68 deletions(-) diff --git a/composer.json b/composer.json index a3335472..1f9c1d96 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "wp-cli/entity-command": "^1.3 || ^2 || ^3", - "wp-cli/wp-cli-tests": "^5" + "wp-cli/wp-cli-tests": "dev-setup-commands-step as 5.3.99" }, "config": { "process-timeout": 7200, diff --git a/features/transient-patch.feature b/features/transient-patch.feature index f588cd9d..0966238b 100644 --- a/features/transient-patch.feature +++ b/features/transient-patch.feature @@ -2,8 +2,10 @@ Feature: Patch command available for the transient cache Scenario: Nested values from transient can be inserted at any depth. Given a WP install - And I run `wp eval "set_transient( 'my_key', ['foo' => 'bar'] );"` - And I run `wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"` + And these setup commands: + | command | + | wp eval "set_transient( 'my_key', ['foo' => 'bar'] );" | + | wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );" | When I run `wp transient patch insert my_key fuz baz` Then STDOUT should be: @@ -73,8 +75,10 @@ Feature: Patch command available for the transient cache Scenario: Nested values from transient can be updated at any depth. Given a WP install - And I run `wp eval "set_transient( 'my_key', ['foo' => 'bar'] );"` - And I run `wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"` + And these setup commands: + | command | + | wp eval "set_transient( 'my_key', ['foo' => 'bar'] );" | + | wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );" | When I run `wp transient patch update my_key foo baz` Then STDOUT should be: @@ -132,8 +136,10 @@ Feature: Patch command available for the transient cache Scenario: Nested values from transient can be deleted at any depth. Given a WP install - And I run `wp eval "set_transient( 'my_key', ['foo' => 'bar'] );"` - And I run `wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"` + And these setup commands: + | command | + | wp eval "set_transient( 'my_key', ['foo' => 'bar'] );" | + | wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );" | When I run `wp transient patch delete my_key foo` Then STDOUT should be: @@ -179,8 +185,10 @@ Feature: Patch command available for the transient cache Scenario: Nested values from site transient can be inserted at any depth. Given a WP multisite install - And I run `wp eval "set_site_transient( 'my_key', ['foo' => 'bar'] );"` - And I run `wp eval "set_site_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"` + And these setup commands: + | command | + | wp eval "set_site_transient( 'my_key', ['foo' => 'bar'] );" | + | wp eval "set_site_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );" | When I run `wp transient patch insert my_key fuz baz --network` Then STDOUT should be: @@ -238,8 +246,10 @@ Feature: Patch command available for the transient cache Scenario: Nested values from site transient can be updated at any depth. Given a WP multisite install - And I run `wp eval "set_site_transient( 'my_key', ['foo' => 'bar'] );"` - And I run `wp eval "set_site_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"` + And these setup commands: + | command | + | wp eval "set_site_transient( 'my_key', ['foo' => 'bar'] );" | + | wp eval "set_site_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );" | When I run `wp transient patch update my_key foo baz --network` Then STDOUT should be: @@ -297,8 +307,10 @@ Feature: Patch command available for the transient cache Scenario: Nested values from site transient can be deleted at any depth. Given a WP multisite install - And I run `wp eval "set_site_transient( 'my_key', ['foo' => 'bar'] );"` - And I run `wp eval "set_site_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"` + And these setup commands: + | command | + | wp eval "set_site_transient( 'my_key', ['foo' => 'bar'] );" | + | wp eval "set_site_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );" | When I run `wp transient patch delete my_key foo --network` Then STDOUT should be: diff --git a/features/transient-pluck.feature b/features/transient-pluck.feature index baaef81d..60e6b2b7 100644 --- a/features/transient-pluck.feature +++ b/features/transient-pluck.feature @@ -2,8 +2,10 @@ Feature: Pluck command available for the transient cache Scenario: Nested values from transient can be retrieved at any depth. Given a WP install - And I run `wp eval "set_transient( 'my_key', ['foo' => 'bar'] );"` - And I run `wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"` + And these setup commands: + | command | + | wp eval "set_transient( 'my_key', ['foo' => 'bar'] );" | + | wp eval "set_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );" | When I run `wp transient pluck my_key foo` Then STDOUT should be: @@ -37,8 +39,10 @@ Feature: Pluck command available for the transient cache Scenario: Nested values from site transient can be retrieved at any depth. Given a WP multisite install - And I run `wp eval "set_site_transient( 'my_key', ['foo' => 'bar'] );"` - And I run `wp eval "set_site_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );"` + And these setup commands: + | command | + | wp eval "set_site_transient( 'my_key', ['foo' => 'bar'] );" | + | wp eval "set_site_transient( 'my_key_2', ['foo' => ['bar' => 'baz']] );" | When I run `wp transient pluck my_key foo --network` Then STDOUT should be: diff --git a/features/transient.feature b/features/transient.feature index 10111b0a..8ab882f7 100644 --- a/features/transient.feature +++ b/features/transient.feature @@ -73,10 +73,12 @@ Feature: Manage WordPress transient cache Error: Please specify transient key, or use --all or --expired. """ - When I run `wp transient set foo bar` - And I run `wp transient set foo2 bar2 600` - And I run `wp transient set foo3 bar3 --network` - And I run `wp transient set foo4 bar4 600 --network` + Given these setup commands: + | command | + | wp transient set foo bar | + | wp transient set foo2 bar2 600 | + | wp transient set foo3 bar3 --network | + | wp transient set foo4 bar4 600 --network | And I run `wp transient delete --all` Then STDOUT should be: @@ -129,13 +131,17 @@ Feature: Manage WordPress transient cache @skip-object-cache Scenario: Deleting expired transients on single site Given a WP install - And I run `wp transient set foo bar 600` - And I run `wp transient set foo2 bar2 600` - And I run `wp transient set foo3 bar3 600 --network` - And I run `wp transient set foo4 bar4 600 --network` + And these setup commands: + | command | + | wp transient set foo bar 600 | + | wp transient set foo2 bar2 600 | + | wp transient set foo3 bar3 600 --network | + | wp transient set foo4 bar4 600 --network | # Change timeout to be in the past. - And I run `wp option update _transient_timeout_foo 1321009871` - And I run `wp option update _site_transient_timeout_foo3 1321009871` + And these setup commands: + | command | + | wp option update _transient_timeout_foo 1321009871 | + | wp option update _site_transient_timeout_foo3 1321009871 | When I run `wp transient delete --expired` Then STDOUT should be: @@ -216,13 +222,15 @@ Feature: Manage WordPress transient cache Error: Please specify transient key, or use --all or --expired. """ - When I run `wp transient set foo bar` - And I run `wp transient set foo2 bar2 600` - And I run `wp transient set foo3 bar3 --network` - And I run `wp transient set foo4 bar4 600 --network` - And I run `wp --url=example.com/foo transient set foo5 bar5 --network` - And I run `wp --url=example.com/foo transient set foo6 bar6 600 --network` - And I run `wp transient delete --all` + Given these setup commands: + | command | + | wp transient set foo bar | + | wp transient set foo2 bar2 600 | + | wp transient set foo3 bar3 --network | + | wp transient set foo4 bar4 600 --network | + | wp --url=example.com/foo transient set foo5 bar5 --network | + | wp --url=example.com/foo transient set foo6 bar6 600 --network | + When I run `wp transient delete --all` Then STDOUT should be: """ Success: {EXPECTED_TRANSIENTS} transients deleted from the database. @@ -298,16 +306,20 @@ Feature: Manage WordPress transient cache Scenario: Deleting expired transients on multisite Given a WP multisite install And I run `wp site create --slug=foo` - And I run `wp transient set foo bar 600` - And I run `wp transient set foo2 bar2 600` - And I run `wp transient set foo3 bar3 600 --network` - And I run `wp transient set foo4 bar4 600 --network` - And I run `wp --url=example.com/foo transient set foo5 bar5 600 --network` - And I run `wp --url=example.com/foo transient set foo6 bar6 600 --network` + And these setup commands: + | command | + | wp transient set foo bar 600 | + | wp transient set foo2 bar2 600 | + | wp transient set foo3 bar3 600 --network | + | wp transient set foo4 bar4 600 --network | + | wp --url=example.com/foo transient set foo5 bar5 600 --network | + | wp --url=example.com/foo transient set foo6 bar6 600 --network | # Change timeout to be in the past. - And I run `wp option update _transient_timeout_foo 1321009871` - And I run `wp site option update _site_transient_timeout_foo3 1321009871` - And I run `wp --url=example.com/foo site option update _site_transient_timeout_foo5 1321009871` + And these setup commands: + | command | + | wp option update _transient_timeout_foo 1321009871 | + | wp site option update _site_transient_timeout_foo3 1321009871 | + | wp --url=example.com/foo site option update _site_transient_timeout_foo5 1321009871 | When I run `wp transient delete --expired` Then STDOUT should be: @@ -398,16 +410,18 @@ Feature: Manage WordPress transient cache @skip-object-cache Scenario: List transients on single site Given a WP install - And I run `wp transient set foo bar` - And I run `wp transient set foo2 bar2 610` - And I run `wp option update _transient_timeout_foo2 95649119999` - And I run `wp transient set foo3 bar3 300` - And I run `wp option update _transient_timeout_foo3 1321009871` - And I run `wp transient set foo4 bar4 --network` - And I run `wp transient set foo5 bar5 610 --network` - And I run `wp option update _site_transient_timeout_foo5 95649119999` - And I run `wp transient set foo6 bar6 300 --network` - And I run `wp option update _site_transient_timeout_foo6 1321009871` + And these setup commands: + | command | + | wp transient set foo bar | + | wp transient set foo2 bar2 610 | + | wp option update _transient_timeout_foo2 95649119999 | + | wp transient set foo3 bar3 300 | + | wp option update _transient_timeout_foo3 1321009871 | + | wp transient set foo4 bar4 --network | + | wp transient set foo5 bar5 610 --network | + | wp option update _site_transient_timeout_foo5 95649119999 | + | wp transient set foo6 bar6 300 --network | + | wp option update _site_transient_timeout_foo6 1321009871 | When I run `wp transient list --format=csv` Then STDOUT should contain: @@ -457,16 +471,18 @@ Feature: Manage WordPress transient cache # We set `WP_DEVELOPMENT_MODE` to stop WordPress from automatically creating # additional transients which cause some steps to fail when testing. And I run `wp config set WP_DEVELOPMENT_MODE all` - And I run `wp transient set foo bar` - And I run `wp transient set foo2 bar2 610` - And I run `wp option update _transient_timeout_foo2 95649119999` - And I run `wp transient set foo3 bar3 300` - And I run `wp option update _transient_timeout_foo3 1321009871` - And I run `wp transient set foo4 bar4 --network` - And I run `wp transient set foo5 bar5 610 --network` - And I run `wp site option update _site_transient_timeout_foo5 95649119999` - And I run `wp transient set foo6 bar6 300 --network` - And I run `wp site option update _site_transient_timeout_foo6 1321009871` + And these setup commands: + | command | + | wp transient set foo bar | + | wp transient set foo2 bar2 610 | + | wp option update _transient_timeout_foo2 95649119999 | + | wp transient set foo3 bar3 300 | + | wp option update _transient_timeout_foo3 1321009871 | + | wp transient set foo4 bar4 --network | + | wp transient set foo5 bar5 610 --network | + | wp site option update _site_transient_timeout_foo5 95649119999 | + | wp transient set foo6 bar6 300 --network | + | wp site option update _site_transient_timeout_foo6 1321009871 | When I run `wp transient list --format=csv` Then STDOUT should contain: @@ -513,11 +529,13 @@ Feature: Manage WordPress transient cache @skip-object-cache Scenario: List transients with search and exclude pattern Given a WP install - And I run `wp transient set foo bar` - And I run `wp transient set foo2 bar2` - And I run `wp transient set foo3 bar3` - And I run `wp transient set foo4 bar4 --network` - And I run `wp transient set foo5 bar5 --network` + And these setup commands: + | command | + | wp transient set foo bar | + | wp transient set foo2 bar2 | + | wp transient set foo3 bar3 | + | wp transient set foo4 bar4 --network | + | wp transient set foo5 bar5 --network | When I run `wp transient list --format=csv --fields=name --search="foo"` Then STDOUT should be: From 1753d331386ec0f7363409cda0f3fd9563395d05 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Sat, 31 Oct 2026 00:37:35 +0100 Subject: [PATCH 2/2] Keep commands that change how WordPress is loaded out of shared processes Co-Authored-By: Claude Opus 5.5 --- features/transient.feature | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/features/transient.feature b/features/transient.feature index 8ab882f7..91932a49 100644 --- a/features/transient.feature +++ b/features/transient.feature @@ -223,14 +223,14 @@ Feature: Manage WordPress transient cache """ Given these setup commands: - | command | - | wp transient set foo bar | - | wp transient set foo2 bar2 600 | - | wp transient set foo3 bar3 --network | - | wp transient set foo4 bar4 600 --network | - | wp --url=example.com/foo transient set foo5 bar5 --network | - | wp --url=example.com/foo transient set foo6 bar6 600 --network | - When I run `wp transient delete --all` + | command | + | wp transient set foo bar | + | wp transient set foo2 bar2 600 | + | wp transient set foo3 bar3 --network | + | wp transient set foo4 bar4 600 --network | + When I run `wp --url=example.com/foo transient set foo5 bar5 --network` + And I run `wp --url=example.com/foo transient set foo6 bar6 600 --network` + And I run `wp transient delete --all` Then STDOUT should be: """ Success: {EXPECTED_TRANSIENTS} transients deleted from the database. @@ -307,19 +307,19 @@ Feature: Manage WordPress transient cache Given a WP multisite install And I run `wp site create --slug=foo` And these setup commands: - | command | - | wp transient set foo bar 600 | - | wp transient set foo2 bar2 600 | - | wp transient set foo3 bar3 600 --network | - | wp transient set foo4 bar4 600 --network | - | wp --url=example.com/foo transient set foo5 bar5 600 --network | - | wp --url=example.com/foo transient set foo6 bar6 600 --network | + | command | + | wp transient set foo bar 600 | + | wp transient set foo2 bar2 600 | + | wp transient set foo3 bar3 600 --network | + | wp transient set foo4 bar4 600 --network | + And I run `wp --url=example.com/foo transient set foo5 bar5 600 --network` + And I run `wp --url=example.com/foo transient set foo6 bar6 600 --network` # Change timeout to be in the past. And these setup commands: - | command | - | wp option update _transient_timeout_foo 1321009871 | - | wp site option update _site_transient_timeout_foo3 1321009871 | - | wp --url=example.com/foo site option update _site_transient_timeout_foo5 1321009871 | + | command | + | wp option update _transient_timeout_foo 1321009871 | + | wp site option update _site_transient_timeout_foo3 1321009871 | + And I run `wp --url=example.com/foo site option update _site_transient_timeout_foo5 1321009871` When I run `wp transient delete --expired` Then STDOUT should be: