diff --git a/composer.json b/composer.json index fcd353184..7b8ac2c4c 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "wp-cli/extension-command": "^1.2 || ^2 || ^3", "wp-cli/media-command": "^1.1 || ^2 || ^3", "wp-cli/super-admin-command": "^1 || ^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/comment-recount.feature b/features/comment-recount.feature index af8737159..ed083231f 100644 --- a/features/comment-recount.feature +++ b/features/comment-recount.feature @@ -3,9 +3,11 @@ Feature: Recount comments on a post Scenario: Recount comments on a post Given a WP install - When I run `wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain` - And I run `wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain` - And I run `wp post get 1 --field=comment_count` + Given these setup commands: + | command | + | wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain | + | wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain | + When I run `wp post get 1 --field=comment_count` Then STDOUT should be: """ 3 diff --git a/features/comment.feature b/features/comment.feature index c51a5095a..ac9c9be9a 100644 --- a/features/comment.feature +++ b/features/comment.feature @@ -48,9 +48,11 @@ Feature: Manage WordPress comments """ And the return code should be 1 - When I run `wp comment create --comment_post_ID=1` - And I run `wp comment create --comment_post_ID=1` - And I run `wp comment delete 3 4` + Given these setup commands: + | command | + | wp comment create --comment_post_ID=1 | + | wp comment create --comment_post_ID=1 | + When I run `wp comment delete 3 4` Then STDOUT should be: """ Success: Trashed comment 3. diff --git a/features/menu-location.feature b/features/menu-location.feature index 1568eafd7..d7df72b03 100644 --- a/features/menu-location.feature +++ b/features/menu-location.feature @@ -11,9 +11,11 @@ Feature: Manage WordPress menu locations | location | description | | primary | Primary Menu | - When I run `wp menu create "Primary Menu"` - And I run `wp menu location assign primary-menu primary` - And I run `wp menu list --fields=slug,locations` + Given these setup commands: + | command | + | wp menu create "Primary Menu" | + | wp menu location assign primary-menu primary | + When I run `wp menu list --fields=slug,locations` Then STDOUT should be a table containing rows: | slug | locations | | primary-menu | primary | diff --git a/features/menu.feature b/features/menu.feature index 7059f9414..a20af0459 100644 --- a/features/menu.feature +++ b/features/menu.feature @@ -25,9 +25,11 @@ Feature: Manage WordPress menus 0 """ - When I run `wp menu create "First Menu"` - And I run `wp menu create "Second Menu"` - And I run `wp menu list --fields=name,slug` + Given these setup commands: + | command | + | wp menu create "First Menu" | + | wp menu create "Second Menu" | + When I run `wp menu list --fields=name,slug` Then STDOUT should be a table containing rows: | name | slug | | First Menu | first-menu | diff --git a/features/option-list.feature b/features/option-list.feature index 38bd86925..43bb2cbec 100644 --- a/features/option-list.feature +++ b/features/option-list.feature @@ -36,8 +36,10 @@ Feature: List WordPress options @skip-object-cache Scenario: Using the `--autoload=on` flag excludes transients by default Given a WP install - And I run `wp option add sample_autoload_option 'sample_autoload_option' --autoload=yes` - And I run `wp transient set sample_autoload_transient 'sample_autoload_transient'` + And these setup commands: + | command | + | wp option add sample_autoload_option 'sample_autoload_option' --autoload=yes | + | wp transient set sample_autoload_transient 'sample_autoload_transient' | When I run `wp option list --autoload=on` Then STDOUT should contain: @@ -62,9 +64,11 @@ Feature: List WordPress options Scenario: List option with exclude pattern Given a WP install - When I run `wp option add sample_test_field_one sample_test_field_value_one` - And I run `wp option add sample_test_field_two sample_test_field_value_two` - And I run `wp option list --search="sample_test_field_*" --format=csv` + Given these setup commands: + | command | + | wp option add sample_test_field_one sample_test_field_value_one | + | wp option add sample_test_field_two sample_test_field_value_two | + When I run `wp option list --search="sample_test_field_*" --format=csv` Then STDOUT should be: """ option_name,option_value @@ -93,8 +97,10 @@ Feature: List WordPress options Scenario: List option with sorting option Given a WP install - And I run `wp option add sample_test_field_one sample_test_field_value_one` - And I run `wp option add sample_test_field_two sample_test_field_value_two` + And these setup commands: + | command | + | wp option add sample_test_field_one sample_test_field_value_one | + | wp option add sample_test_field_two sample_test_field_value_two | When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_id --order=asc` Then STDOUT should be: @@ -178,10 +184,12 @@ Feature: List WordPress options Scenario: Using the `--autoload=on` flag Given a WP install - And I run `wp option add sample_autoload_one 'sample_value_one' --autoload=yes` - And I run `wp option add sample_autoload_two 'sample_value_two' --autoload=no` - And I run `wp option add sample_autoload_three 'sample_value_three' --autoload=on` - And I run `wp option add sample_autoload_four 'sample_value_four' --autoload=off` + And these setup commands: + | command | + | wp option add sample_autoload_one 'sample_value_one' --autoload=yes | + | wp option add sample_autoload_two 'sample_value_two' --autoload=no | + | wp option add sample_autoload_three 'sample_value_three' --autoload=on | + | wp option add sample_autoload_four 'sample_value_four' --autoload=off | When I run `wp option list --autoload=on` Then STDOUT should not contain: @@ -203,10 +211,12 @@ Feature: List WordPress options Scenario: Using the `--autoload=off` flag Given a WP install - And I run `wp option add sample_autoload_one 'sample_value_one' --autoload=yes` - And I run `wp option add sample_autoload_two 'sample_value_two' --autoload=no` - And I run `wp option add sample_autoload_three 'sample_value_three' --autoload=on` - And I run `wp option add sample_autoload_four 'sample_value_four' --autoload=off` + And these setup commands: + | command | + | wp option add sample_autoload_one 'sample_value_one' --autoload=yes | + | wp option add sample_autoload_two 'sample_value_two' --autoload=no | + | wp option add sample_autoload_three 'sample_value_three' --autoload=on | + | wp option add sample_autoload_four 'sample_value_four' --autoload=off | When I run `wp option list --autoload=off` Then STDOUT should not contain: diff --git a/features/post.feature b/features/post.feature index 313260c4f..4a2abf027 100644 --- a/features/post.feature +++ b/features/post.feature @@ -394,9 +394,11 @@ Feature: Manage WordPress posts | Sample Page | sample-page | publish | Scenario: List posts with date query - When I run `wp post create --post_title='old post' --post_date='2023-01-24T09:52:00.000Z'` - And I run `wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z'` - And I run `wp post list --field=post_title --date_query='{"before":{"year":"2024"}}'` + Given these setup commands: + | command | + | wp post create --post_title='old post' --post_date='2023-01-24T09:52:00.000Z' | + | wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z' | + When I run `wp post list --field=post_title --date_query='{"before":{"year":"2024"}}'` Then STDOUT should contain: """ old post @@ -407,12 +409,14 @@ Feature: Manage WordPress posts """ Scenario: List posts with tax query - When I run `wp term create category "First Category" --porcelain` - And I run `wp term create category "Second Category" --porcelain` - And I run `wp post create --post_title='post-1' --post_category="First Category"` - And I run `wp post create --post_title='post-2' --post_category="Second Category"` - And I run `wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z'` - And I run `wp post list --field=post_title --tax_query='[{"taxonomy":"category","field":"slug","terms":"first-category"}]'` + Given these setup commands: + | command | + | wp term create category "First Category" --porcelain | + | wp term create category "Second Category" --porcelain | + | wp post create --post_title='post-1' --post_category="First Category" | + | wp post create --post_title='post-2' --post_category="Second Category" | + | wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z' | + When I run `wp post list --field=post_title --tax_query='[{"taxonomy":"category","field":"slug","terms":"first-category"}]'` Then STDOUT should contain: """ post-1 @@ -423,13 +427,13 @@ Feature: Manage WordPress posts """ Scenario: Creating/updating posts with taxonomies - When I run `wp term create category "First Category" --porcelain` - And save STDOUT as {CAT_1} - And I run `wp term create category "Second Category" --porcelain` - And save STDOUT as {CAT_2} - And I run `wp term create post_tag "Term One" --porcelain` - And I run `wp term create post_tag "Term Two" --porcelain` - And I run `wp post create --post_title='Test Post' --post_content='Test post content' --tax_input='{"category":[{CAT_1},{CAT_2}],"post_tag":["term-one", "term-two"]}' --porcelain` + Given these setup commands: + | command | save | + | wp term create category "First Category" --porcelain | CAT_1 | + | wp term create category "Second Category" --porcelain | CAT_2 | + | wp term create post_tag "Term One" --porcelain | | + | wp term create post_tag "Term Two" --porcelain | | + When I run `wp post create --post_title='Test Post' --post_content='Test post content' --tax_input='{"category":[{CAT_1},{CAT_2}],"post_tag":["term-one", "term-two"]}' --porcelain` Then STDOUT should be a number And save STDOUT as {POST_ID} diff --git a/features/signup.feature b/features/signup.feature index aeecb2ec6..5a6f4b31a 100644 --- a/features/signup.feature +++ b/features/signup.feature @@ -11,8 +11,10 @@ Feature: Manage signups in a multisite installation Scenario: List signups Given a WP multisite install - And I run `wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );"` - And I run `wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );"` + And these setup commands: + | command | + | wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );" | + | wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );" | When I run `wp user signup list --fields=signup_id,user_login,user_email,active --format=csv` Then STDOUT should be: @@ -101,8 +103,10 @@ Feature: Manage signups in a multisite installation Scenario: Activate multiple signups Given a WP multisite install - And I run `wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );"` - And I run `wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );"` + And these setup commands: + | command | + | wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );" | + | wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );" | When I run `wp user signup list --active=0 --format=count` Then STDOUT should be: @@ -147,8 +151,10 @@ Feature: Manage signups in a multisite installation Scenario: Delete signups Given a WP multisite install - And I run `wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );"` - And I run `wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );"` + And these setup commands: + | command | + | wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );" | + | wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );" | When I run `wp user signup get bobuser --field=user_email` Then STDOUT should be: @@ -176,8 +182,10 @@ Feature: Manage signups in a multisite installation Scenario: Delete all signups Given a WP multisite install - And I run `wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );"` - And I run `wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );"` + And these setup commands: + | command | + | wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );" | + | wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );" | When I try `wp user signup delete` Then STDERR should be: @@ -199,10 +207,12 @@ Feature: Manage signups in a multisite installation Scenario: Expose add_to_blog, new_role, and blog_id fields and support filtering by them Given a WP multisite install - And I run `wp eval "wpmu_signup_user( 'adminuser', 'adminuser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'administrator' ) );"` - And I run `wp eval "wpmu_signup_user( 'editoruser', 'editoruser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'editor' ) );"` - And I run `wp eval "wpmu_signup_user( 'otherbloguser', 'otherbloguser@example.com', array( 'add_to_blog' => 300, 'new_role' => 'administrator' ) );"` - And I run `wp eval "wpmu_signup_user( 'plainuser', 'plainuser@example.com' );"` + And these setup commands: + | command | + | wp eval "wpmu_signup_user( 'adminuser', 'adminuser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'administrator' ) );" | + | wp eval "wpmu_signup_user( 'editoruser', 'editoruser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'editor' ) );" | + | wp eval "wpmu_signup_user( 'otherbloguser', 'otherbloguser@example.com', array( 'add_to_blog' => 300, 'new_role' => 'administrator' ) );" | + | wp eval "wpmu_signup_user( 'plainuser', 'plainuser@example.com' );" | When I run `wp user signup list --active=0 --new_role=administrator --fields=user_login,new_role,blog_id --format=csv` Then STDOUT should be: @@ -248,10 +258,12 @@ Feature: Manage signups in a multisite installation Scenario: Filter signups by metadata with per_page pagination Given a WP multisite install - And I run `wp eval "wpmu_signup_user( 'plainuser', 'plainuser@example.com' );"` - And I run `wp eval "wpmu_signup_user( 'adminuser', 'adminuser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'administrator' ) );"` - And I run `wp eval "wpmu_signup_user( 'editoruser', 'editoruser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'editor' ) );"` - And I run `wp eval "wpmu_signup_user( 'otherbloguser', 'otherbloguser@example.com', array( 'add_to_blog' => 300, 'new_role' => 'administrator' ) );"` + And these setup commands: + | command | + | wp eval "wpmu_signup_user( 'plainuser', 'plainuser@example.com' );" | + | wp eval "wpmu_signup_user( 'adminuser', 'adminuser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'administrator' ) );" | + | wp eval "wpmu_signup_user( 'editoruser', 'editoruser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'editor' ) );" | + | wp eval "wpmu_signup_user( 'otherbloguser', 'otherbloguser@example.com', array( 'add_to_blog' => 300, 'new_role' => 'administrator' ) );" | When I run `wp user signup list --blog_id=228 --per_page=2 --fields=user_login,blog_id --format=csv` Then STDOUT should be: diff --git a/features/user-application-password.feature b/features/user-application-password.feature index c2779900b..71c954f4b 100644 --- a/features/user-application-password.feature +++ b/features/user-application-password.feature @@ -88,11 +88,13 @@ Feature: Manage user custom fields When I try `wp user application-password get 1 {UUID}` Then the return code should be 1 - When I run `wp user application-password create 1 myapp1` - And I run `wp user application-password create 1 myapp2` - And I run `wp user application-password create 1 myapp3` - And I run `wp user application-password create 1 myapp4` - And I run `wp user application-password create 1 myapp5` + Given these setup commands: + | command | + | wp user application-password create 1 myapp1 | + | wp user application-password create 1 myapp2 | + | wp user application-password create 1 myapp3 | + | wp user application-password create 1 myapp4 | + When I run `wp user application-password create 1 myapp5` Then STDOUT should not be empty When I run `wp user application-password list 1 --format=count` diff --git a/features/user-import-csv.feature b/features/user-import-csv.feature index 802ffb92e..83d32a903 100644 --- a/features/user-import-csv.feature +++ b/features/user-import-csv.feature @@ -108,8 +108,10 @@ Feature: Import users from CSV Given a WP install When I run `wp user delete 1 --yes` - And I run `wp user create bobjones bobjones@example.com --display_name="Bob Jones" --role=contributor` - And I run `wp user create billjones billjones@example.com --display_name="Bill Jones" --role=administrator` + And these setup commands: + | command | + | wp user create bobjones bobjones@example.com --display_name="Bob Jones" --role=contributor | + | wp user create billjones billjones@example.com --display_name="Bill Jones" --role=administrator | And I run `wp user add-role billjones author` Then STDOUT should not be empty diff --git a/features/user-list.feature b/features/user-list.feature index 073d325fc..2bd717c45 100644 --- a/features/user-list.feature +++ b/features/user-list.feature @@ -3,8 +3,10 @@ Feature: List WordPress users @require-wp-4.4 Scenario: List users of specific roles Given a WP install - And I run `wp user create bobjones bob@example.com --role=author` - And I run `wp user create sally sally@example.com --role=editor` + And these setup commands: + | command | + | wp user create bobjones bob@example.com --role=author | + | wp user create sally sally@example.com --role=editor | When I run `wp user list --field=user_login` Then STDOUT should be: diff --git a/features/user-meta.feature b/features/user-meta.feature index 685606a42..f3f90ed5d 100644 --- a/features/user-meta.feature +++ b/features/user-meta.feature @@ -34,9 +34,11 @@ Feature: Manage user custom meta fields When I try `wp user meta get 1 foo` Then the return code should be 1 - When I run `wp user meta add 1 foo bar` - And I run `wp user meta add 1 foo bar2` - And I run `wp user meta add 1 foo bar3` + Given these setup commands: + | command | + | wp user meta add 1 foo bar | + | wp user meta add 1 foo bar2 | + When I run `wp user meta add 1 foo bar3` Then STDOUT should not be empty When I run `wp user meta delete 1 foo bar2` diff --git a/features/user-session.feature b/features/user-session.feature index e68db294b..06c268b90 100644 --- a/features/user-session.feature +++ b/features/user-session.feature @@ -5,11 +5,13 @@ Feature: Manage user session @require-wp-4.0 Scenario: Destroy user sessions - When I run `wp eval 'wp_set_current_user(1);'` - And I run `wp eval 'wp_set_auth_cookie(1);'` - And I run `wp eval 'wp_set_current_user(1);'` - And I run `wp eval 'wp_set_auth_cookie(1);'` - And I run `wp user session list admin --format=count` + Given these setup commands: + | command | + | wp eval 'wp_set_current_user(1);' | + | wp eval 'wp_set_auth_cookie(1);' | + | wp eval 'wp_set_current_user(1);' | + | wp eval 'wp_set_auth_cookie(1);' | + When I run `wp user session list admin --format=count` Then STDOUT should be: """ 2 diff --git a/features/user.feature b/features/user.feature index ff97085e0..30ff6b80a 100644 --- a/features/user.feature +++ b/features/user.feature @@ -667,10 +667,10 @@ Feature: Manage WordPress users Scenario: Mark/remove a user from spam Given a WP multisite install - And I run `wp user create bumblebee bbee@example.com --role=author --porcelain` - And save STDOUT as {BBEE_ID} - And I run `wp user create oprime oprime@example.com --role=author --porcelain` - And save STDOUT as {OP_ID} + And these setup commands: + | command | save | + | wp user create bumblebee bbee@example.com --role=author --porcelain | BBEE_ID | + | wp user create oprime oprime@example.com --role=author --porcelain | OP_ID | And I run `wp user get bumblebee` And STDOUT should not be empty And I run `wp user get oprime`