Skip to content

Commit cf68e1f

Browse files
authored
Merge pull request #465 from wp-cli/fix/tests
Fix tests for Hello Dolly
2 parents fa25c55 + 01a8c62 commit cf68e1f

8 files changed

+138
-80
lines changed

features/plugin-activate.feature

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,20 @@ Feature: Activate WordPress plugins
2121
"""
2222
And the return code should be 1
2323

24-
When I try `wp plugin activate akismet hello debug-bar`
24+
When I try `wp plugin activate akismet debug-bar`
2525
Then STDERR should be:
2626
"""
2727
Warning: The 'debug-bar' plugin could not be found.
28-
Error: Only activated 2 of 3 plugins.
28+
Error: Only activated 1 of 2 plugins.
2929
"""
3030
And STDOUT should be:
3131
"""
3232
Plugin 'akismet' activated.
33-
Plugin 'hello' activated.
3433
"""
3534
And the return code should be 1
3635

3736
Scenario: Activate all when one plugin is hidden by "all_plugins" filter
38-
Given I run `wp plugin install site-secrets`
37+
Given I run `wp plugin install site-secrets https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip`
3938
And a wp-content/mu-plugins/hide-us-plugin.php file:
4039
"""
4140
<?php
@@ -55,7 +54,10 @@ Feature: Activate WordPress plugins
5554
Then STDOUT should contain:
5655
"""
5756
Plugin 'akismet' activated.
58-
Plugin 'hello' activated.
57+
"""
58+
And STDOUT should contain:
59+
"""
60+
Plugin 'sample-plugin' activated.
5961
"""
6062
And STDOUT should not contain:
6163
"""
@@ -135,7 +137,7 @@ Feature: Activate WordPress plugins
135137
"""
136138

137139
Scenario: Adding --exclude with plugin activate --all should exclude the plugins specified via --exclude
138-
When I try `wp plugin activate --all --exclude=hello`
140+
When I try `wp plugin activate --all --exclude=hello,hello-dolly`
139141
Then STDOUT should be:
140142
"""
141143
Plugin 'akismet' activated.

features/plugin-auto-updates-disable.feature

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Feature: Disable auto-updates for WordPress plugins
22

33
Background:
44
Given a WP install
5-
And I run `wp plugin install duplicate-post --ignore-requirements`
5+
And I run `wp plugin install duplicate-post https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip --ignore-requirements`
66
And I run `wp plugin auto-updates enable --all`
77

88
@require-wp-5.5
@@ -16,7 +16,7 @@ Feature: Disable auto-updates for WordPress plugins
1616

1717
@require-wp-5.5
1818
Scenario: Disable auto-updates for a single plugin
19-
When I run `wp plugin auto-updates disable hello`
19+
When I run `wp plugin auto-updates disable sample-plugin`
2020
Then STDOUT should be:
2121
"""
2222
Success: Disabled 1 of 1 plugin auto-updates.
@@ -25,7 +25,7 @@ Feature: Disable auto-updates for WordPress plugins
2525

2626
@require-wp-5.5
2727
Scenario: Disable auto-updates for multiple plugins
28-
When I run `wp plugin auto-updates disable hello duplicate-post`
28+
When I run `wp plugin auto-updates disable sample-plugin duplicate-post`
2929
Then STDOUT should be:
3030
"""
3131
Success: Disabled 2 of 2 plugin auto-updates.
@@ -46,20 +46,20 @@ Feature: Disable auto-updates for WordPress plugins
4646

4747
@require-wp-5.5
4848
Scenario: Disable auto-updates for already disabled plugins
49-
When I run `wp plugin auto-updates disable hello`
49+
When I run `wp plugin auto-updates disable sample-plugin`
5050
And I try `wp plugin auto-updates disable --all`
5151
Then STDERR should contain:
5252
"""
53-
Warning: Auto-updates already disabled for plugin hello.
53+
Warning: Auto-updates already disabled for plugin sample-plugin.
5454
"""
5555
And STDERR should contain:
5656
"""
57-
Error: Only disabled 2 of 3 plugin auto-updates.
57+
Error: Only disabled 3 of 4 plugin auto-updates.
5858
"""
5959

6060
@require-wp-5.5
6161
Scenario: Filter when disabling auto-updates for already enabled plugins
62-
When I run `wp plugin auto-updates disable hello`
62+
When I run `wp plugin auto-updates disable sample-plugin`
6363
And I run `wp plugin list --auto_update=on --format=count`
6464
Then save STDOUT as {PLUGIN_COUNT}
6565

@@ -72,8 +72,8 @@ Feature: Disable auto-updates for WordPress plugins
7272

7373
@require-wp-5.5
7474
Scenario: Filter when disabling auto-updates for already disabled selection of plugins
75-
When I run `wp plugin auto-updates disable hello`
76-
And I run `wp plugin auto-updates disable hello duplicate-post --enabled-only`
75+
When I run `wp plugin auto-updates disable sample-plugin`
76+
And I run `wp plugin auto-updates disable sample-plugin duplicate-post --enabled-only`
7777
Then STDOUT should be:
7878
"""
7979
Success: Disabled 1 of 1 plugin auto-updates.
@@ -82,8 +82,8 @@ Feature: Disable auto-updates for WordPress plugins
8282

8383
@require-wp-5.5
8484
Scenario: Filtering everything away produces an error
85-
When I run `wp plugin auto-updates disable hello`
86-
And I try `wp plugin auto-updates disable hello --enabled-only`
85+
When I run `wp plugin auto-updates disable sample-plugin`
86+
And I try `wp plugin auto-updates disable sample-plugin --enabled-only`
8787
Then STDERR should be:
8888
"""
8989
Error: No plugins provided to disable auto-updates for.

features/plugin-auto-updates-enable.feature

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Feature: Enable auto-updates for WordPress plugins
22

33
Background:
44
Given a WP install
5-
And I run `wp plugin install duplicate-post --ignore-requirements`
5+
And I run `wp plugin install duplicate-post https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip --ignore-requirements`
66

77
@require-wp-5.5
88
Scenario: Show an error if required params are missing
@@ -15,7 +15,7 @@ Feature: Enable auto-updates for WordPress plugins
1515

1616
@require-wp-5.5
1717
Scenario: Enable auto-updates for a single plugin
18-
When I run `wp plugin auto-updates enable hello`
18+
When I run `wp plugin auto-updates enable sample-plugin`
1919
Then STDOUT should be:
2020
"""
2121
Success: Enabled 1 of 1 plugin auto-updates.
@@ -24,7 +24,7 @@ Feature: Enable auto-updates for WordPress plugins
2424

2525
@require-wp-5.5
2626
Scenario: Enable auto-updates for multiple plugins
27-
When I run `wp plugin auto-updates enable hello duplicate-post`
27+
When I run `wp plugin auto-updates enable sample-plugin duplicate-post`
2828
Then STDOUT should be:
2929
"""
3030
Success: Enabled 2 of 2 plugin auto-updates.
@@ -45,20 +45,20 @@ Feature: Enable auto-updates for WordPress plugins
4545

4646
@require-wp-5.5
4747
Scenario: Enable auto-updates for already enabled plugins
48-
When I run `wp plugin auto-updates enable hello`
48+
When I run `wp plugin auto-updates enable sample-plugin`
4949
And I try `wp plugin auto-updates enable --all`
5050
Then STDERR should contain:
5151
"""
52-
Warning: Auto-updates already enabled for plugin hello.
52+
Warning: Auto-updates already enabled for plugin sample-plugin.
5353
"""
5454
And STDERR should contain:
5555
"""
56-
Error: Only enabled 2 of 3 plugin auto-updates.
56+
Error: Only enabled 3 of 4 plugin auto-updates.
5757
"""
5858

5959
@require-wp-5.5
6060
Scenario: Filter when enabling auto-updates for already enabled plugins
61-
When I run `wp plugin auto-updates enable hello`
61+
When I run `wp plugin auto-updates enable sample-plugin`
6262
And I run `wp plugin list --status=inactive --auto_update=off --format=count`
6363
Then save STDOUT as {PLUGIN_COUNT}
6464

@@ -71,8 +71,8 @@ Feature: Enable auto-updates for WordPress plugins
7171

7272
@require-wp-5.5
7373
Scenario: Filter when enabling auto-updates for already enabled selection of plugins
74-
When I run `wp plugin auto-updates enable hello`
75-
And I run `wp plugin auto-updates enable hello duplicate-post --disabled-only`
74+
When I run `wp plugin auto-updates enable sample-plugin`
75+
And I run `wp plugin auto-updates enable sample-plugin duplicate-post --disabled-only`
7676
Then STDOUT should be:
7777
"""
7878
Success: Enabled 1 of 1 plugin auto-updates.
@@ -81,8 +81,8 @@ Feature: Enable auto-updates for WordPress plugins
8181

8282
@require-wp-5.5
8383
Scenario: Filtering everything away produces an error
84-
When I run `wp plugin auto-updates enable hello`
85-
And I try `wp plugin auto-updates enable hello --disabled-only`
84+
When I run `wp plugin auto-updates enable sample-plugin`
85+
And I try `wp plugin auto-updates enable sample-plugin --disabled-only`
8686
Then STDERR should be:
8787
"""
8888
Error: No plugins provided to enable auto-updates for.

features/plugin-auto-updates-status.feature

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Feature: Show the status of auto-updates for WordPress plugins
22

33
Background:
44
Given a WP install
5-
And I run `wp plugin install duplicate-post --ignore-requirements`
5+
And I run `wp plugin install duplicate-post https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip --ignore-requirements`
66

77
@require-wp-5.5
88
Scenario: Show an error if required params are missing
@@ -15,19 +15,19 @@ Feature: Show the status of auto-updates for WordPress plugins
1515

1616
@require-wp-5.5
1717
Scenario: Show the status of auto-updates of a single plugin
18-
When I run `wp plugin auto-updates status hello`
18+
When I run `wp plugin auto-updates status sample-plugin`
1919
Then STDOUT should be a table containing rows:
2020
| name | status |
21-
| hello | disabled |
21+
| sample-plugin | disabled |
2222
And the return code should be 0
2323

2424
@require-wp-5.5
2525
Scenario: Show the status of auto-updates multiple plugins
26-
When I run `wp plugin auto-updates status duplicate-post hello`
26+
When I run `wp plugin auto-updates status duplicate-post sample-plugin`
2727
Then STDOUT should be a table containing rows:
2828
| name | status |
2929
| duplicate-post | disabled |
30-
| hello | disabled |
30+
| sample-plugin | disabled |
3131
And the return code should be 0
3232

3333
@require-wp-5.5
@@ -37,7 +37,7 @@ Feature: Show the status of auto-updates for WordPress plugins
3737
| name | status |
3838
| akismet | disabled |
3939
| duplicate-post | disabled |
40-
| hello | disabled |
40+
| sample-plugin | disabled |
4141
And the return code should be 0
4242

4343
When I run `wp plugin auto-updates enable --all`
@@ -46,25 +46,25 @@ Feature: Show the status of auto-updates for WordPress plugins
4646
| name | status |
4747
| akismet | enabled |
4848
| duplicate-post | enabled |
49-
| hello | enabled |
49+
| sample-plugin | enabled |
5050
And the return code should be 0
5151

5252
@require-wp-5.5
5353
Scenario: The status can be filtered to only show enabled or disabled plugins
54-
Given I run `wp plugin auto-updates enable hello`
54+
Given I run `wp plugin auto-updates enable sample-plugin`
5555

5656
When I run `wp plugin auto-updates status --all`
5757
Then STDOUT should be a table containing rows:
5858
| name | status |
5959
| akismet | disabled |
6060
| duplicate-post | disabled |
61-
| hello | enabled |
61+
| sample-plugin | enabled |
6262
And the return code should be 0
6363

6464
When I run `wp plugin auto-updates status --all --enabled-only`
6565
Then STDOUT should be a table containing rows:
6666
| name | status |
67-
| hello | enabled |
67+
| sample-plugin | enabled |
6868
And the return code should be 0
6969

7070
When I run `wp plugin auto-updates status --all --disabled-only`
@@ -83,16 +83,19 @@ Feature: Show the status of auto-updates for WordPress plugins
8383

8484
@require-wp-5.5
8585
Scenario: The fields can be shown individually
86-
Given I run `wp plugin auto-updates enable hello`
86+
Given I run `wp plugin auto-updates enable sample-plugin`
8787

8888
When I run `wp plugin auto-updates status --all --disabled-only --field=name`
89-
Then STDOUT should be:
89+
Then STDOUT should contain:
9090
"""
9191
akismet
92+
"""
93+
And STDOUT should contain:
94+
"""
9295
duplicate-post
9396
"""
9497

95-
When I run `wp plugin auto-updates status hello --field=status`
98+
When I run `wp plugin auto-updates status sample-plugin --field=status`
9699
Then STDOUT should be:
97100
"""
98101
enabled
@@ -101,23 +104,36 @@ Feature: Show the status of auto-updates for WordPress plugins
101104
@require-wp-5.5
102105
Scenario: Formatting options work
103106
When I run `wp plugin auto-updates status --all --format=json`
104-
Then STDOUT should be:
107+
Then STDOUT should contain:
108+
"""
109+
{"name":"akismet","status":"disabled"}
110+
"""
111+
And STDOUT should contain:
112+
"""
113+
{"name":"sample-plugin","status":"disabled"}
105114
"""
106-
[{"name":"akismet","status":"disabled"},{"name":"hello","status":"disabled"},{"name":"duplicate-post","status":"disabled"}]
115+
And STDOUT should contain:
116+
"""
117+
{"name":"duplicate-post","status":"disabled"}
107118
"""
108119

109120
When I run `wp plugin auto-updates status --all --format=csv`
110-
Then STDOUT should be:
121+
Then STDOUT should contain:
111122
"""
112-
name,status
113123
akismet,disabled
114-
hello,disabled
124+
"""
125+
And STDOUT should contain:
126+
"""
127+
sample-plugin,disabled
128+
"""
129+
And STDOUT should contain:
130+
"""
115131
duplicate-post,disabled
116132
"""
117133

118134
@require-wp-5.5
119135
Scenario: Handle malformed option value
120136
When I run `wp option update auto_update_plugins ""`
121-
And I try `wp plugin auto-updates status hello`
137+
And I try `wp plugin auto-updates status sample-plugin`
122138
Then the return code should be 0
123139
And STDERR should be empty

features/plugin-deactivate.feature

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Feature: Deactivate WordPress plugins
22

33
Background:
44
Given a WP install
5-
And I run `wp plugin activate akismet hello`
5+
And I run `wp plugin install https://github.com/wp-cli/sample-plugin/archive/refs/heads/master.zip`
6+
And I run `wp plugin activate akismet sample-plugin`
67

78
Scenario: Deactivate a plugin that's already activated
89
When I run `wp plugin deactivate akismet`
@@ -23,7 +24,7 @@ Feature: Deactivate WordPress plugins
2324
And STDOUT should be empty
2425
And the return code should be 1
2526

26-
When I try `wp plugin deactivate akismet hello debug-bar`
27+
When I try `wp plugin deactivate akismet sample-plugin debug-bar`
2728
Then STDERR should be:
2829
"""
2930
Warning: The 'debug-bar' plugin could not be found.
@@ -32,7 +33,7 @@ Feature: Deactivate WordPress plugins
3233
And STDOUT should be:
3334
"""
3435
Plugin 'akismet' deactivated.
35-
Plugin 'hello' deactivated.
36+
Plugin 'sample-plugin' deactivated.
3637
"""
3738
And the return code should be 1
3839

@@ -78,16 +79,19 @@ Feature: Deactivate WordPress plugins
7879
"""
7980

8081
Scenario: Adding --exclude with plugin deactivate --all should exclude the plugins specified via --exclude
81-
When I try `wp plugin deactivate --all --exclude=hello`
82-
Then STDOUT should be:
82+
When I try `wp plugin deactivate --all --exclude=sample-plugin`
83+
Then STDOUT should contain:
8384
"""
8485
Plugin 'akismet' deactivated.
85-
Success: Deactivated 1 of 1 plugins.
86+
"""
87+
And STDOUT should contain:
88+
"""
89+
Success: Deactivated 1 of 2 plugins.
8690
"""
8791
And the return code should be 0
8892

8993
Scenario: Adding --exclude with plugin deactivate should throw an error unless --all given
90-
When I try `wp plugin deactivate --exclude=hello`
94+
When I try `wp plugin deactivate --exclude=sample-plugin`
9195
Then the return code should be 1
9296
And STDERR should be:
9397
"""

0 commit comments

Comments
 (0)