Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commands to manage auto-updates for plugins and themes #259

Merged
merged 6 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extension-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
}

WP_CLI::add_command( 'plugin', 'Plugin_Command' );
WP_CLI::add_command( 'plugin auto-updates', 'Plugin_AutoUpdates_Command' );
WP_CLI::add_command( 'theme', 'Theme_Command' );
WP_CLI::add_command( 'theme auto-updates', 'Theme_AutoUpdates_Command' );
WP_CLI::add_command( 'theme mod', 'Theme_Mod_Command' );
76 changes: 76 additions & 0 deletions features/plugin-auto-updates-disable.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Feature: Disable auto-updates for WordPress plugins

Background:
Given a WP install
And I run `wp plugin install duplicate-post`
And I run `wp plugin auto-updates enable --all`

Scenario: Show an error if required params are missing
When I try `wp plugin auto-updates disable`
Then STDOUT should be empty
And STDERR should contain:
"""
Error: Please specify one or more plugins, or use --all.
"""

Scenario: Disable auto-updates for a single plugin
When I run `wp plugin auto-updates disable hello`
Then STDOUT should be:
"""
Success: Disabled 1 of 1 plugin auto-updates.
"""
And the return code should be 0

Scenario: Disable auto-updates for multiple plugins
When I run `wp plugin auto-updates disable hello duplicate-post`
Then STDOUT should be:
"""
Success: Disabled 2 of 2 plugin auto-updates.
"""
And the return code should be 0

Scenario: Disable auto-updates for all plugins
When I run `wp plugin auto-updates disable --all`
Then STDOUT should be:
"""
Success: Disabled 3 of 3 plugin auto-updates.
"""
And the return code should be 0

Scenario: Disable auto-updates for already disabled plugins
When I run `wp plugin auto-updates disable hello`
And I try `wp plugin auto-updates disable --all`
Then STDERR should contain:
"""
Warning: Auto-updates already disabled for plugin hello.
"""
And STDERR should contain:
"""
Error: Only disabled 2 of 3 plugin auto-updates.
"""

Scenario: Filter when enabling auto-updates for already disabled plugins
When I run `wp plugin auto-updates disable hello`
And I run `wp plugin auto-updates disable --all --enabled-only`
Then STDOUT should be:
"""
Success: Disabled 2 of 2 plugin auto-updates.
"""
And the return code should be 0

Scenario: Filter when enabling auto-updates for already disabled selection of plugins
When I run `wp plugin auto-updates disable hello`
And I run `wp plugin auto-updates disable hello duplicate-post --enabled-only`
Then STDOUT should be:
"""
Success: Disabled 1 of 1 plugin auto-updates.
"""
And the return code should be 0

Scenario: Filtering everything away produces an error
When I run `wp plugin auto-updates disable hello`
And I try `wp plugin auto-updates disable hello --enabled-only`
Then STDERR should be:
"""
Error: No plugins provided to disable auto-updates for.
"""
75 changes: 75 additions & 0 deletions features/plugin-auto-updates-enable.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Feature: Enable auto-updates for WordPress plugins

Background:
Given a WP install
And I run `wp plugin install duplicate-post`

Scenario: Show an error if required params are missing
When I try `wp plugin auto-updates enable`
Then STDOUT should be empty
And STDERR should contain:
"""
Error: Please specify one or more plugins, or use --all.
"""

Scenario: Enable auto-updates for a single plugin
When I run `wp plugin auto-updates enable hello`
Then STDOUT should be:
"""
Success: Enabled 1 of 1 plugin auto-updates.
"""
And the return code should be 0

Scenario: Enable auto-updates for multiple plugins
When I run `wp plugin auto-updates enable hello duplicate-post`
Then STDOUT should be:
"""
Success: Enabled 2 of 2 plugin auto-updates.
"""
And the return code should be 0

Scenario: Enable auto-updates for all plugins
When I run `wp plugin auto-updates enable --all`
Then STDOUT should be:
"""
Success: Enabled 3 of 3 plugin auto-updates.
"""
And the return code should be 0

Scenario: Enable auto-updates for already enabled plugins
When I run `wp plugin auto-updates enable hello`
And I try `wp plugin auto-updates enable --all`
Then STDERR should contain:
"""
Warning: Auto-updates already enabled for plugin hello.
"""
And STDERR should contain:
"""
Error: Only enabled 2 of 3 plugin auto-updates.
"""

Scenario: Filter when enabling auto-updates for already enabled plugins
When I run `wp plugin auto-updates enable hello`
And I run `wp plugin auto-updates enable --all --disabled-only`
Then STDOUT should be:
"""
Success: Enabled 2 of 2 plugin auto-updates.
"""
And the return code should be 0

Scenario: Filter when enabling auto-updates for already enabled selection of plugins
When I run `wp plugin auto-updates enable hello`
And I run `wp plugin auto-updates enable hello duplicate-post --disabled-only`
Then STDOUT should be:
"""
Success: Enabled 1 of 1 plugin auto-updates.
"""
And the return code should be 0

Scenario: Filtering everything away produces an error
When I run `wp plugin auto-updates enable hello`
And I try `wp plugin auto-updates enable hello --disabled-only`
Then STDERR should be:
"""
Error: No plugins provided to enable auto-updates for.
"""
93 changes: 93 additions & 0 deletions features/plugin-auto-updates-status.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Feature: Show the status of auto-updates for WordPress plugins

Background:
Given a WP install
And I run `wp plugin install duplicate-post`

Scenario: Show an error if required params are missing
When I try `wp plugin auto-updates status`
Then STDOUT should be empty
And STDERR should contain:
"""
Error: Please specify one or more plugins, or use --all.
"""

Scenario: Show the status of auto-updates of a single plugin
When I run `wp plugin auto-updates status hello`
Then STDOUT should be a table containing rows:
| name | status |
| hello | disabled |
And the return code should be 0

Scenario: Show the status of auto-updates multiple plugins
When I run `wp plugin auto-updates status duplicate-post hello`
Then STDOUT should be a table containing rows:
| name | status |
| duplicate-post | disabled |
| hello | disabled |
And the return code should be 0

Scenario: Show the status of auto-updates all installed plugins
When I run `wp plugin auto-updates status --all`
Then STDOUT should be a table containing rows:
| name | status |
| akismet | disabled |
| duplicate-post | disabled |
| hello | disabled |
And the return code should be 0

When I run `wp plugin auto-updates enable --all`
And I run `wp plugin auto-updates status --all`
Then STDOUT should be a table containing rows:
| name | status |
| akismet | enabled |
| duplicate-post | enabled |
| hello | enabled |
And the return code should be 0

Scenario: The status can be filtered to only show enabled or disabled plugins
Given I run `wp plugin auto-updates enable hello`

When I run `wp plugin auto-updates status --all`
Then STDOUT should be a table containing rows:
| name | status |
| akismet | disabled |
| duplicate-post | disabled |
| hello | enabled |
And the return code should be 0

When I run `wp plugin auto-updates status --all --enabled-only`
Then STDOUT should be a table containing rows:
| name | status |
| hello | enabled |
And the return code should be 0

When I run `wp plugin auto-updates status --all --disabled-only`
Then STDOUT should be a table containing rows:
| name | status |
| akismet | disabled |
| duplicate-post | disabled |
And the return code should be 0

When I try `wp plugin auto-updates status --all --enabled-only --disabled-only`
Then STDOUT should be empty
And STDERR should contain:
"""
Error: --enabled-only and --disabled-only are mutually exclusive and cannot be used at the same time.
"""

Scenario: The fields can be shown individually
Given I run `wp plugin auto-updates enable hello`

When I run `wp plugin auto-updates status --all --disabled-only --field=name`
Then STDOUT should be:
"""
akismet
duplicate-post
"""

When I run `wp plugin auto-updates status hello --field=status`
Then STDOUT should be:
"""
enabled
"""
96 changes: 96 additions & 0 deletions features/theme-auto-update-status.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Feature: Show the status of auto-updates for WordPress themes

Background:
Given a WP install
And I run `wp theme delete --all --force`
And I run `wp theme install twentysixteen`
And I run `wp theme install twentyseventeen`
And I run `wp theme install twentynineteen`

Scenario: Show an error if required params are missing
When I try `wp theme auto-updates status`
Then STDOUT should be empty
And STDERR should contain:
"""
Error: Please specify one or more themes, or use --all.
"""

Scenario: Show the status of auto-updates of a single theme
When I run `wp theme auto-updates status twentysixteen`
Then STDOUT should be a table containing rows:
| name | status |
| twentysixteen | disabled |
And the return code should be 0

Scenario: Show the status of auto-updates multiple themes
When I run `wp theme auto-updates status twentyseventeen twentysixteen`
Then STDOUT should be a table containing rows:
| name | status |
| twentyseventeen | disabled |
| twentysixteen | disabled |
And the return code should be 0

Scenario: Show the status of auto-updates all installed themes
When I run `wp theme auto-updates status --all`
Then STDOUT should be a table containing rows:
| name | status |
| twentynineteen | disabled |
| twentyseventeen | disabled |
| twentysixteen | disabled |
And the return code should be 0

When I run `wp theme auto-updates enable --all`
And I run `wp theme auto-updates status --all`
Then STDOUT should be a table containing rows:
| name | status |
| twentynineteen | enabled |
| twentyseventeen | enabled |
| twentysixteen | enabled |
And the return code should be 0

Scenario: The status can be filtered to only show enabled or disabled themes
Given I run `wp theme auto-updates enable twentysixteen`

When I run `wp theme auto-updates status --all`
Then STDOUT should be a table containing rows:
| name | status |
| twentynineteen | disabled |
| twentyseventeen | disabled |
| twentysixteen | enabled |
And the return code should be 0

When I run `wp theme auto-updates status --all --enabled-only`
Then STDOUT should be a table containing rows:
| name | status |
| twentysixteen | enabled |
And the return code should be 0

When I run `wp theme auto-updates status --all --disabled-only`
Then STDOUT should be a table containing rows:
| name | status |
| twentynineteen | disabled |
| twentyseventeen | disabled |
And the return code should be 0

When I try `wp theme auto-updates status --all --enabled-only --disabled-only`
Then STDOUT should be empty
And STDERR should contain:
"""
Error: --enabled-only and --disabled-only are mutually exclusive and cannot be used at the same time.
"""

Scenario: The fields can be shown individually
Given I run `wp theme auto-updates enable twentysixteen`

When I run `wp theme auto-updates status --all --disabled-only --field=name`
Then STDOUT should be:
"""
twentynineteen
twentyseventeen
"""

When I run `wp theme auto-updates status twentysixteen --field=status`
Then STDOUT should be:
"""
enabled
"""
Loading