Skip to content

Commit a89a413

Browse files
authored
Merge pull request #259 from wp-cli/add/auto-updates
2 parents a0c97ca + d354536 commit a89a413

15 files changed

+1319
-169
lines changed

extension-command.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010
}
1111

1212
WP_CLI::add_command( 'plugin', 'Plugin_Command' );
13+
WP_CLI::add_command( 'plugin auto-updates', 'Plugin_AutoUpdates_Command' );
1314
WP_CLI::add_command( 'theme', 'Theme_Command' );
15+
WP_CLI::add_command( 'theme auto-updates', 'Theme_AutoUpdates_Command' );
1416
WP_CLI::add_command( 'theme mod', 'Theme_Mod_Command' );
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
Feature: Disable auto-updates for WordPress plugins
2+
3+
Background:
4+
Given a WP install
5+
And I run `wp plugin install duplicate-post`
6+
And I run `wp plugin auto-updates enable --all`
7+
8+
Scenario: Show an error if required params are missing
9+
When I try `wp plugin auto-updates disable`
10+
Then STDOUT should be empty
11+
And STDERR should contain:
12+
"""
13+
Error: Please specify one or more plugins, or use --all.
14+
"""
15+
16+
Scenario: Disable auto-updates for a single plugin
17+
When I run `wp plugin auto-updates disable hello`
18+
Then STDOUT should be:
19+
"""
20+
Success: Disabled 1 of 1 plugin auto-updates.
21+
"""
22+
And the return code should be 0
23+
24+
Scenario: Disable auto-updates for multiple plugins
25+
When I run `wp plugin auto-updates disable hello duplicate-post`
26+
Then STDOUT should be:
27+
"""
28+
Success: Disabled 2 of 2 plugin auto-updates.
29+
"""
30+
And the return code should be 0
31+
32+
Scenario: Disable auto-updates for all plugins
33+
When I run `wp plugin auto-updates disable --all`
34+
Then STDOUT should be:
35+
"""
36+
Success: Disabled 3 of 3 plugin auto-updates.
37+
"""
38+
And the return code should be 0
39+
40+
Scenario: Disable auto-updates for already disabled plugins
41+
When I run `wp plugin auto-updates disable hello`
42+
And I try `wp plugin auto-updates disable --all`
43+
Then STDERR should contain:
44+
"""
45+
Warning: Auto-updates already disabled for plugin hello.
46+
"""
47+
And STDERR should contain:
48+
"""
49+
Error: Only disabled 2 of 3 plugin auto-updates.
50+
"""
51+
52+
Scenario: Filter when enabling auto-updates for already disabled plugins
53+
When I run `wp plugin auto-updates disable hello`
54+
And I run `wp plugin auto-updates disable --all --enabled-only`
55+
Then STDOUT should be:
56+
"""
57+
Success: Disabled 2 of 2 plugin auto-updates.
58+
"""
59+
And the return code should be 0
60+
61+
Scenario: Filter when enabling auto-updates for already disabled selection of plugins
62+
When I run `wp plugin auto-updates disable hello`
63+
And I run `wp plugin auto-updates disable hello duplicate-post --enabled-only`
64+
Then STDOUT should be:
65+
"""
66+
Success: Disabled 1 of 1 plugin auto-updates.
67+
"""
68+
And the return code should be 0
69+
70+
Scenario: Filtering everything away produces an error
71+
When I run `wp plugin auto-updates disable hello`
72+
And I try `wp plugin auto-updates disable hello --enabled-only`
73+
Then STDERR should be:
74+
"""
75+
Error: No plugins provided to disable auto-updates for.
76+
"""
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Feature: Enable auto-updates for WordPress plugins
2+
3+
Background:
4+
Given a WP install
5+
And I run `wp plugin install duplicate-post`
6+
7+
Scenario: Show an error if required params are missing
8+
When I try `wp plugin auto-updates enable`
9+
Then STDOUT should be empty
10+
And STDERR should contain:
11+
"""
12+
Error: Please specify one or more plugins, or use --all.
13+
"""
14+
15+
Scenario: Enable auto-updates for a single plugin
16+
When I run `wp plugin auto-updates enable hello`
17+
Then STDOUT should be:
18+
"""
19+
Success: Enabled 1 of 1 plugin auto-updates.
20+
"""
21+
And the return code should be 0
22+
23+
Scenario: Enable auto-updates for multiple plugins
24+
When I run `wp plugin auto-updates enable hello duplicate-post`
25+
Then STDOUT should be:
26+
"""
27+
Success: Enabled 2 of 2 plugin auto-updates.
28+
"""
29+
And the return code should be 0
30+
31+
Scenario: Enable auto-updates for all plugins
32+
When I run `wp plugin auto-updates enable --all`
33+
Then STDOUT should be:
34+
"""
35+
Success: Enabled 3 of 3 plugin auto-updates.
36+
"""
37+
And the return code should be 0
38+
39+
Scenario: Enable auto-updates for already enabled plugins
40+
When I run `wp plugin auto-updates enable hello`
41+
And I try `wp plugin auto-updates enable --all`
42+
Then STDERR should contain:
43+
"""
44+
Warning: Auto-updates already enabled for plugin hello.
45+
"""
46+
And STDERR should contain:
47+
"""
48+
Error: Only enabled 2 of 3 plugin auto-updates.
49+
"""
50+
51+
Scenario: Filter when enabling auto-updates for already enabled plugins
52+
When I run `wp plugin auto-updates enable hello`
53+
And I run `wp plugin auto-updates enable --all --disabled-only`
54+
Then STDOUT should be:
55+
"""
56+
Success: Enabled 2 of 2 plugin auto-updates.
57+
"""
58+
And the return code should be 0
59+
60+
Scenario: Filter when enabling auto-updates for already enabled selection of plugins
61+
When I run `wp plugin auto-updates enable hello`
62+
And I run `wp plugin auto-updates enable hello duplicate-post --disabled-only`
63+
Then STDOUT should be:
64+
"""
65+
Success: Enabled 1 of 1 plugin auto-updates.
66+
"""
67+
And the return code should be 0
68+
69+
Scenario: Filtering everything away produces an error
70+
When I run `wp plugin auto-updates enable hello`
71+
And I try `wp plugin auto-updates enable hello --disabled-only`
72+
Then STDERR should be:
73+
"""
74+
Error: No plugins provided to enable auto-updates for.
75+
"""
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Feature: Show the status of auto-updates for WordPress plugins
2+
3+
Background:
4+
Given a WP install
5+
And I run `wp plugin install duplicate-post`
6+
7+
Scenario: Show an error if required params are missing
8+
When I try `wp plugin auto-updates status`
9+
Then STDOUT should be empty
10+
And STDERR should contain:
11+
"""
12+
Error: Please specify one or more plugins, or use --all.
13+
"""
14+
15+
Scenario: Show the status of auto-updates of a single plugin
16+
When I run `wp plugin auto-updates status hello`
17+
Then STDOUT should be a table containing rows:
18+
| name | status |
19+
| hello | disabled |
20+
And the return code should be 0
21+
22+
Scenario: Show the status of auto-updates multiple plugins
23+
When I run `wp plugin auto-updates status duplicate-post hello`
24+
Then STDOUT should be a table containing rows:
25+
| name | status |
26+
| duplicate-post | disabled |
27+
| hello | disabled |
28+
And the return code should be 0
29+
30+
Scenario: Show the status of auto-updates all installed plugins
31+
When I run `wp plugin auto-updates status --all`
32+
Then STDOUT should be a table containing rows:
33+
| name | status |
34+
| akismet | disabled |
35+
| duplicate-post | disabled |
36+
| hello | disabled |
37+
And the return code should be 0
38+
39+
When I run `wp plugin auto-updates enable --all`
40+
And I run `wp plugin auto-updates status --all`
41+
Then STDOUT should be a table containing rows:
42+
| name | status |
43+
| akismet | enabled |
44+
| duplicate-post | enabled |
45+
| hello | enabled |
46+
And the return code should be 0
47+
48+
Scenario: The status can be filtered to only show enabled or disabled plugins
49+
Given I run `wp plugin auto-updates enable hello`
50+
51+
When I run `wp plugin auto-updates status --all`
52+
Then STDOUT should be a table containing rows:
53+
| name | status |
54+
| akismet | disabled |
55+
| duplicate-post | disabled |
56+
| hello | enabled |
57+
And the return code should be 0
58+
59+
When I run `wp plugin auto-updates status --all --enabled-only`
60+
Then STDOUT should be a table containing rows:
61+
| name | status |
62+
| hello | enabled |
63+
And the return code should be 0
64+
65+
When I run `wp plugin auto-updates status --all --disabled-only`
66+
Then STDOUT should be a table containing rows:
67+
| name | status |
68+
| akismet | disabled |
69+
| duplicate-post | disabled |
70+
And the return code should be 0
71+
72+
When I try `wp plugin auto-updates status --all --enabled-only --disabled-only`
73+
Then STDOUT should be empty
74+
And STDERR should contain:
75+
"""
76+
Error: --enabled-only and --disabled-only are mutually exclusive and cannot be used at the same time.
77+
"""
78+
79+
Scenario: The fields can be shown individually
80+
Given I run `wp plugin auto-updates enable hello`
81+
82+
When I run `wp plugin auto-updates status --all --disabled-only --field=name`
83+
Then STDOUT should be:
84+
"""
85+
akismet
86+
duplicate-post
87+
"""
88+
89+
When I run `wp plugin auto-updates status hello --field=status`
90+
Then STDOUT should be:
91+
"""
92+
enabled
93+
"""
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
Feature: Show the status of auto-updates for WordPress themes
2+
3+
Background:
4+
Given a WP install
5+
And I run `wp theme delete --all --force`
6+
And I run `wp theme install twentysixteen`
7+
And I run `wp theme install twentyseventeen`
8+
And I run `wp theme install twentynineteen`
9+
10+
Scenario: Show an error if required params are missing
11+
When I try `wp theme auto-updates status`
12+
Then STDOUT should be empty
13+
And STDERR should contain:
14+
"""
15+
Error: Please specify one or more themes, or use --all.
16+
"""
17+
18+
Scenario: Show the status of auto-updates of a single theme
19+
When I run `wp theme auto-updates status twentysixteen`
20+
Then STDOUT should be a table containing rows:
21+
| name | status |
22+
| twentysixteen | disabled |
23+
And the return code should be 0
24+
25+
Scenario: Show the status of auto-updates multiple themes
26+
When I run `wp theme auto-updates status twentyseventeen twentysixteen`
27+
Then STDOUT should be a table containing rows:
28+
| name | status |
29+
| twentyseventeen | disabled |
30+
| twentysixteen | disabled |
31+
And the return code should be 0
32+
33+
Scenario: Show the status of auto-updates all installed themes
34+
When I run `wp theme auto-updates status --all`
35+
Then STDOUT should be a table containing rows:
36+
| name | status |
37+
| twentynineteen | disabled |
38+
| twentyseventeen | disabled |
39+
| twentysixteen | disabled |
40+
And the return code should be 0
41+
42+
When I run `wp theme auto-updates enable --all`
43+
And I run `wp theme auto-updates status --all`
44+
Then STDOUT should be a table containing rows:
45+
| name | status |
46+
| twentynineteen | enabled |
47+
| twentyseventeen | enabled |
48+
| twentysixteen | enabled |
49+
And the return code should be 0
50+
51+
Scenario: The status can be filtered to only show enabled or disabled themes
52+
Given I run `wp theme auto-updates enable twentysixteen`
53+
54+
When I run `wp theme auto-updates status --all`
55+
Then STDOUT should be a table containing rows:
56+
| name | status |
57+
| twentynineteen | disabled |
58+
| twentyseventeen | disabled |
59+
| twentysixteen | enabled |
60+
And the return code should be 0
61+
62+
When I run `wp theme auto-updates status --all --enabled-only`
63+
Then STDOUT should be a table containing rows:
64+
| name | status |
65+
| twentysixteen | enabled |
66+
And the return code should be 0
67+
68+
When I run `wp theme auto-updates status --all --disabled-only`
69+
Then STDOUT should be a table containing rows:
70+
| name | status |
71+
| twentynineteen | disabled |
72+
| twentyseventeen | disabled |
73+
And the return code should be 0
74+
75+
When I try `wp theme auto-updates status --all --enabled-only --disabled-only`
76+
Then STDOUT should be empty
77+
And STDERR should contain:
78+
"""
79+
Error: --enabled-only and --disabled-only are mutually exclusive and cannot be used at the same time.
80+
"""
81+
82+
Scenario: The fields can be shown individually
83+
Given I run `wp theme auto-updates enable twentysixteen`
84+
85+
When I run `wp theme auto-updates status --all --disabled-only --field=name`
86+
Then STDOUT should be:
87+
"""
88+
twentynineteen
89+
twentyseventeen
90+
"""
91+
92+
When I run `wp theme auto-updates status twentysixteen --field=status`
93+
Then STDOUT should be:
94+
"""
95+
enabled
96+
"""

0 commit comments

Comments
 (0)