Skip to content

Commit a9a5c39

Browse files
schlesseraclaude
andauthored
Run setup commands in a single process in tests (#679)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 82d63d0 commit a9a5c39

13 files changed

Lines changed: 124 additions & 80 deletions

‎features/comment-recount.feature‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ Feature: Recount comments on a post
33
Scenario: Recount comments on a post
44
Given a WP install
55

6-
When I run `wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain`
7-
And I run `wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain`
8-
And I run `wp post get 1 --field=comment_count`
6+
And these setup commands:
7+
| command |
8+
| wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain |
9+
| wp comment create --comment_post_ID=1 --comment_approved=1 --porcelain |
10+
When I run `wp post get 1 --field=comment_count`
911
Then STDOUT should be:
1012
"""
1113
3

‎features/comment.feature‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ Feature: Manage WordPress comments
4848
"""
4949
And the return code should be 1
5050

51-
When I run `wp comment create --comment_post_ID=1`
52-
And I run `wp comment create --comment_post_ID=1`
53-
And I run `wp comment delete 3 4`
51+
Given these setup commands:
52+
| command |
53+
| wp comment create --comment_post_ID=1 |
54+
| wp comment create --comment_post_ID=1 |
55+
When I run `wp comment delete 3 4`
5456
Then STDOUT should be:
5557
"""
5658
Success: Trashed comment 3.

‎features/menu-location.feature‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ Feature: Manage WordPress menu locations
1313
| location | description |
1414
| primary | Primary Menu |
1515

16-
When I run `wp menu create "Primary Menu"`
17-
And I run `wp menu location assign primary-menu primary`
18-
And I run `wp menu list --fields=slug,locations`
16+
Given these setup commands:
17+
| command |
18+
| wp menu create "Primary Menu" |
19+
| wp menu location assign primary-menu primary |
20+
When I run `wp menu list --fields=slug,locations`
1921
Then STDOUT should be a table containing rows:
2022
| slug | locations |
2123
| primary-menu | primary |

‎features/menu.feature‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ Feature: Manage WordPress menus
2525
0
2626
"""
2727

28-
When I run `wp menu create "First Menu"`
29-
And I run `wp menu create "Second Menu"`
30-
And I run `wp menu list --fields=name,slug`
28+
Given these setup commands:
29+
| command |
30+
| wp menu create "First Menu" |
31+
| wp menu create "Second Menu" |
32+
When I run `wp menu list --fields=name,slug`
3133
Then STDOUT should be a table containing rows:
3234
| name | slug |
3335
| First Menu | first-menu |

‎features/option-list.feature‎

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ Feature: List WordPress options
3636
@skip-object-cache
3737
Scenario: Using the `--autoload=on` flag excludes transients by default
3838
Given a WP install
39-
And I run `wp option add sample_autoload_option 'sample_autoload_option' --autoload=yes`
40-
And I run `wp transient set sample_autoload_transient 'sample_autoload_transient'`
39+
And these setup commands:
40+
| command |
41+
| wp option add sample_autoload_option 'sample_autoload_option' --autoload=yes |
42+
| wp transient set sample_autoload_transient 'sample_autoload_transient' |
4143

4244
When I run `wp option list --autoload=on`
4345
Then STDOUT should contain:
@@ -62,9 +64,11 @@ Feature: List WordPress options
6264
Scenario: List option with exclude pattern
6365
Given a WP install
6466

65-
When I run `wp option add sample_test_field_one sample_test_field_value_one`
66-
And I run `wp option add sample_test_field_two sample_test_field_value_two`
67-
And I run `wp option list --search="sample_test_field_*" --format=csv`
67+
And these setup commands:
68+
| command |
69+
| wp option add sample_test_field_one sample_test_field_value_one |
70+
| wp option add sample_test_field_two sample_test_field_value_two |
71+
When I run `wp option list --search="sample_test_field_*" --format=csv`
6872
Then STDOUT should be:
6973
"""
7074
option_name,option_value
@@ -93,8 +97,10 @@ Feature: List WordPress options
9397

9498
Scenario: List option with sorting option
9599
Given a WP install
96-
And I run `wp option add sample_test_field_one sample_test_field_value_one`
97-
And I run `wp option add sample_test_field_two sample_test_field_value_two`
100+
And these setup commands:
101+
| command |
102+
| wp option add sample_test_field_one sample_test_field_value_one |
103+
| wp option add sample_test_field_two sample_test_field_value_two |
98104

99105
When I run `wp option list --search="sample_test_field_*" --format=csv --orderby=option_id --order=asc`
100106
Then STDOUT should be:
@@ -178,10 +184,12 @@ Feature: List WordPress options
178184

179185
Scenario: Using the `--autoload=on` flag
180186
Given a WP install
181-
And I run `wp option add sample_autoload_one 'sample_value_one' --autoload=yes`
182-
And I run `wp option add sample_autoload_two 'sample_value_two' --autoload=no`
183-
And I run `wp option add sample_autoload_three 'sample_value_three' --autoload=on`
184-
And I run `wp option add sample_autoload_four 'sample_value_four' --autoload=off`
187+
And these setup commands:
188+
| command |
189+
| wp option add sample_autoload_one 'sample_value_one' --autoload=yes |
190+
| wp option add sample_autoload_two 'sample_value_two' --autoload=no |
191+
| wp option add sample_autoload_three 'sample_value_three' --autoload=on |
192+
| wp option add sample_autoload_four 'sample_value_four' --autoload=off |
185193

186194
When I run `wp option list --autoload=on`
187195
Then STDOUT should not contain:
@@ -203,10 +211,12 @@ Feature: List WordPress options
203211

204212
Scenario: Using the `--autoload=off` flag
205213
Given a WP install
206-
And I run `wp option add sample_autoload_one 'sample_value_one' --autoload=yes`
207-
And I run `wp option add sample_autoload_two 'sample_value_two' --autoload=no`
208-
And I run `wp option add sample_autoload_three 'sample_value_three' --autoload=on`
209-
And I run `wp option add sample_autoload_four 'sample_value_four' --autoload=off`
214+
And these setup commands:
215+
| command |
216+
| wp option add sample_autoload_one 'sample_value_one' --autoload=yes |
217+
| wp option add sample_autoload_two 'sample_value_two' --autoload=no |
218+
| wp option add sample_autoload_three 'sample_value_three' --autoload=on |
219+
| wp option add sample_autoload_four 'sample_value_four' --autoload=off |
210220

211221
When I run `wp option list --autoload=off`
212222
Then STDOUT should not contain:

‎features/post.feature‎

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,11 @@ Feature: Manage WordPress posts
395395
| Sample Page | sample-page | publish |
396396

397397
Scenario: List posts with date query
398-
When I run `wp post create --post_title='old post' --post_date='2023-01-24T09:52:00.000Z'`
399-
And I run `wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z'`
400-
And I run `wp post list --field=post_title --date_query='{"before":{"year":"2024"}}'`
398+
Given these setup commands:
399+
| command |
400+
| wp post create --post_title='old post' --post_date='2023-01-24T09:52:00.000Z' |
401+
| wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z' |
402+
When I run `wp post list --field=post_title --date_query='{"before":{"year":"2024"}}'`
401403
Then STDOUT should contain:
402404
"""
403405
old post
@@ -408,12 +410,14 @@ Feature: Manage WordPress posts
408410
"""
409411

410412
Scenario: List posts with tax query
411-
When I run `wp term create category "First Category" --porcelain`
412-
And I run `wp term create category "Second Category" --porcelain`
413-
And I run `wp post create --post_title='post-1' --post_category="First Category"`
414-
And I run `wp post create --post_title='post-2' --post_category="Second Category"`
415-
And I run `wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z'`
416-
And I run `wp post list --field=post_title --tax_query='[{"taxonomy":"category","field":"slug","terms":"first-category"}]'`
413+
Given these setup commands:
414+
| command |
415+
| wp term create category "First Category" --porcelain |
416+
| wp term create category "Second Category" --porcelain |
417+
| wp post create --post_title='post-1' --post_category="First Category" |
418+
| wp post create --post_title='post-2' --post_category="Second Category" |
419+
| wp post create --post_title='new post' --post_date='2025-01-24T09:52:00.000Z' |
420+
When I run `wp post list --field=post_title --tax_query='[{"taxonomy":"category","field":"slug","terms":"first-category"}]'`
417421
Then STDOUT should contain:
418422
"""
419423
post-1
@@ -424,13 +428,13 @@ Feature: Manage WordPress posts
424428
"""
425429

426430
Scenario: Creating/updating posts with taxonomies
427-
When I run `wp term create category "First Category" --porcelain`
428-
And save STDOUT as {CAT_1}
429-
And I run `wp term create category "Second Category" --porcelain`
430-
And save STDOUT as {CAT_2}
431-
And I run `wp term create post_tag "Term One" --porcelain`
432-
And I run `wp term create post_tag "Term Two" --porcelain`
433-
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`
431+
Given these setup commands:
432+
| command | save |
433+
| wp term create category "First Category" --porcelain | CAT_1 |
434+
| wp term create category "Second Category" --porcelain | CAT_2 |
435+
| wp term create post_tag "Term One" --porcelain | |
436+
| wp term create post_tag "Term Two" --porcelain | |
437+
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`
434438
Then STDOUT should be a number
435439
And save STDOUT as {POST_ID}
436440

‎features/signup.feature‎

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ Feature: Manage signups in a multisite installation
1111

1212
Scenario: List signups
1313
Given a WP multisite install
14-
And I run `wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );"`
15-
And I run `wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );"`
14+
And these setup commands:
15+
| command |
16+
| wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );" |
17+
| wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );" |
1618

1719
When I run `wp user signup list --fields=signup_id,user_login,user_email,active --format=csv`
1820
Then STDOUT should be:
@@ -101,8 +103,10 @@ Feature: Manage signups in a multisite installation
101103

102104
Scenario: Activate multiple signups
103105
Given a WP multisite install
104-
And I run `wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );"`
105-
And I run `wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );"`
106+
And these setup commands:
107+
| command |
108+
| wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );" |
109+
| wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );" |
106110

107111
When I run `wp user signup list --active=0 --format=count`
108112
Then STDOUT should be:
@@ -147,8 +151,10 @@ Feature: Manage signups in a multisite installation
147151

148152
Scenario: Delete signups
149153
Given a WP multisite install
150-
And I run `wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );"`
151-
And I run `wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );"`
154+
And these setup commands:
155+
| command |
156+
| wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );" |
157+
| wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );" |
152158

153159
When I run `wp user signup get bobuser --field=user_email`
154160
Then STDOUT should be:
@@ -176,8 +182,10 @@ Feature: Manage signups in a multisite installation
176182

177183
Scenario: Delete all signups
178184
Given a WP multisite install
179-
And I run `wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );"`
180-
And I run `wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );"`
185+
And these setup commands:
186+
| command |
187+
| wp eval "wpmu_signup_user( 'bobuser', 'bobuser@example.com' );" |
188+
| wp eval "wpmu_signup_user( 'johnuser', 'johnuser@example.com' );" |
181189

182190
When I try `wp user signup delete`
183191
Then STDERR should be:
@@ -199,10 +207,12 @@ Feature: Manage signups in a multisite installation
199207

200208
Scenario: Expose add_to_blog, new_role, and blog_id fields and support filtering by them
201209
Given a WP multisite install
202-
And I run `wp eval "wpmu_signup_user( 'adminuser', 'adminuser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'administrator' ) );"`
203-
And I run `wp eval "wpmu_signup_user( 'editoruser', 'editoruser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'editor' ) );"`
204-
And I run `wp eval "wpmu_signup_user( 'otherbloguser', 'otherbloguser@example.com', array( 'add_to_blog' => 300, 'new_role' => 'administrator' ) );"`
205-
And I run `wp eval "wpmu_signup_user( 'plainuser', 'plainuser@example.com' );"`
210+
And these setup commands:
211+
| command |
212+
| wp eval "wpmu_signup_user( 'adminuser', 'adminuser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'administrator' ) );" |
213+
| wp eval "wpmu_signup_user( 'editoruser', 'editoruser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'editor' ) );" |
214+
| wp eval "wpmu_signup_user( 'otherbloguser', 'otherbloguser@example.com', array( 'add_to_blog' => 300, 'new_role' => 'administrator' ) );" |
215+
| wp eval "wpmu_signup_user( 'plainuser', 'plainuser@example.com' );" |
206216

207217
When I run `wp user signup list --active=0 --new_role=administrator --fields=user_login,new_role,blog_id --format=csv`
208218
Then STDOUT should be:
@@ -248,10 +258,12 @@ Feature: Manage signups in a multisite installation
248258

249259
Scenario: Filter signups by metadata with per_page pagination
250260
Given a WP multisite install
251-
And I run `wp eval "wpmu_signup_user( 'plainuser', 'plainuser@example.com' );"`
252-
And I run `wp eval "wpmu_signup_user( 'adminuser', 'adminuser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'administrator' ) );"`
253-
And I run `wp eval "wpmu_signup_user( 'editoruser', 'editoruser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'editor' ) );"`
254-
And I run `wp eval "wpmu_signup_user( 'otherbloguser', 'otherbloguser@example.com', array( 'add_to_blog' => 300, 'new_role' => 'administrator' ) );"`
261+
And these setup commands:
262+
| command |
263+
| wp eval "wpmu_signup_user( 'plainuser', 'plainuser@example.com' );" |
264+
| wp eval "wpmu_signup_user( 'adminuser', 'adminuser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'administrator' ) );" |
265+
| wp eval "wpmu_signup_user( 'editoruser', 'editoruser@example.com', array( 'add_to_blog' => 228, 'new_role' => 'editor' ) );" |
266+
| wp eval "wpmu_signup_user( 'otherbloguser', 'otherbloguser@example.com', array( 'add_to_blog' => 300, 'new_role' => 'administrator' ) );" |
255267

256268
When I run `wp user signup list --blog_id=228 --per_page=2 --fields=user_login,blog_id --format=csv`
257269
Then STDOUT should be:

‎features/user-application-password.feature‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ Feature: Manage user custom fields
9191
When I try `wp user application-password get 1 {UUID}`
9292
Then the return code should be 1
9393

94-
When I run `wp user application-password create 1 myapp1`
95-
And I run `wp user application-password create 1 myapp2`
96-
And I run `wp user application-password create 1 myapp3`
97-
And I run `wp user application-password create 1 myapp4`
98-
And I run `wp user application-password create 1 myapp5`
94+
Given these setup commands:
95+
| command |
96+
| wp user application-password create 1 myapp1 |
97+
| wp user application-password create 1 myapp2 |
98+
| wp user application-password create 1 myapp3 |
99+
| wp user application-password create 1 myapp4 |
100+
When I run `wp user application-password create 1 myapp5`
99101
Then STDOUT should not be empty
100102

101103
When I run `wp user application-password list 1 --format=count`

‎features/user-import-csv.feature‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,10 @@ Feature: Import users from CSV
108108
Given a WP install
109109

110110
When I run `wp user delete 1 --yes`
111-
And I run `wp user create bobjones bobjones@example.com --display_name="Bob Jones" --role=contributor`
112-
And I run `wp user create billjones billjones@example.com --display_name="Bill Jones" --role=administrator`
111+
And these setup commands:
112+
| command |
113+
| wp user create bobjones bobjones@example.com --display_name="Bob Jones" --role=contributor |
114+
| wp user create billjones billjones@example.com --display_name="Bill Jones" --role=administrator |
113115
And I run `wp user add-role billjones author`
114116
Then STDOUT should not be empty
115117

‎features/user-list.feature‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ Feature: List WordPress users
33
@require-wp-4.4
44
Scenario: List users of specific roles
55
Given a WP install
6-
And I run `wp user create bobjones bob@example.com --role=author`
7-
And I run `wp user create sally sally@example.com --role=editor`
6+
And these setup commands:
7+
| command |
8+
| wp user create bobjones bob@example.com --role=author |
9+
| wp user create sally sally@example.com --role=editor |
810

911
When I run `wp user list --field=user_login`
1012
Then STDOUT should be:

0 commit comments

Comments
 (0)