diff --git a/features/plugin-auto-updates-disable.feature b/features/plugin-auto-updates-disable.feature index e749e452..662c85f6 100644 --- a/features/plugin-auto-updates-disable.feature +++ b/features/plugin-auto-updates-disable.feature @@ -32,25 +32,19 @@ Feature: Disable auto-updates for WordPress plugins """ And the return code should be 0 - @require-wp-5.5 @require-mysql + @require-wp-5.5 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 + When I run `wp plugin list --status=inactive --format=count` + Then save STDOUT as {PLUGIN_COUNT} - @require-wp-5.5 @require-sqlite - Scenario: Disable auto-updates for all plugins When I run `wp plugin auto-updates disable --all` Then STDOUT should be: """ - Success: Disabled 4 of 4 plugin auto-updates. + Success: Disabled {PLUGIN_COUNT} of {PLUGIN_COUNT} plugin auto-updates. """ And the return code should be 0 - @require-wp-5.5 @require-mysql + @require-wp-5.5 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` @@ -63,41 +57,22 @@ Feature: Disable auto-updates for WordPress plugins Error: Only disabled 2 of 3 plugin auto-updates. """ - @require-wp-5.5 @require-sqlite - Scenario: Disable auto-updates for already disabled plugins + @require-wp-5.5 + Scenario: Filter when disabling auto-updates for already enabled 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 3 of 4 plugin auto-updates. - """ - @require-wp-5.5 @require-mysql - 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 + When I run `wp plugin list --auto_update=on --format=count` + Then save STDOUT as {PLUGIN_COUNT} - @require-wp-5.5 @require-sqlite - 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` + When I run `wp plugin auto-updates disable --all --enabled-only` Then STDOUT should be: """ - Success: Disabled 3 of 3 plugin auto-updates. + Success: Disabled {PLUGIN_COUNT} of {PLUGIN_COUNT} plugin auto-updates. """ And the return code should be 0 @require-wp-5.5 - Scenario: Filter when enabling auto-updates for already disabled selection of plugins + Scenario: Filter when disabling 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: diff --git a/features/plugin-auto-updates-enable.feature b/features/plugin-auto-updates-enable.feature index 8b4205f8..8646136a 100644 --- a/features/plugin-auto-updates-enable.feature +++ b/features/plugin-auto-updates-enable.feature @@ -31,25 +31,19 @@ Feature: Enable auto-updates for WordPress plugins """ And the return code should be 0 - @require-wp-5.5 @require-mysql + @require-wp-5.5 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 + When I run `wp plugin list --status=inactive --format=count` + Then save STDOUT as {PLUGIN_COUNT} - @require-wp-5.5 @require-sqlite - Scenario: Enable auto-updates for all plugins When I run `wp plugin auto-updates enable --all` Then STDOUT should be: """ - Success: Enabled 4 of 4 plugin auto-updates. + Success: Enabled {PLUGIN_COUNT} of {PLUGIN_COUNT} plugin auto-updates. """ And the return code should be 0 - @require-wp-5.5 @require-mysql + @require-wp-5.5 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` @@ -62,36 +56,16 @@ Feature: Enable auto-updates for WordPress plugins Error: Only enabled 2 of 3 plugin auto-updates. """ - @require-wp-5.5 @require-sqlite - 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 3 of 4 plugin auto-updates. - """ - - @require-wp-5.5 @require-mysql + @require-wp-5.5 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 + And I run `wp plugin list --status=inactive --auto_update=off --format=count` + Then save STDOUT as {PLUGIN_COUNT} - @require-wp-5.5 @require-sqlite - 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` + When I run `wp plugin auto-updates enable --all --disabled-only` Then STDOUT should be: """ - Success: Enabled 3 of 3 plugin auto-updates. + Success: Enabled {PLUGIN_COUNT} of {PLUGIN_COUNT} plugin auto-updates. """ And the return code should be 0 diff --git a/features/plugin-auto-updates-status.feature b/features/plugin-auto-updates-status.feature index 39ef039a..76843d08 100644 --- a/features/plugin-auto-updates-status.feature +++ b/features/plugin-auto-updates-status.feature @@ -81,24 +81,7 @@ Feature: Show the status of auto-updates for WordPress plugins Error: --enabled-only and --disabled-only are mutually exclusive and cannot be used at the same time. """ - @require-wp-5.5 @require-mysql - 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 - """ - - @require-wp-5.5 @require-sqlite + @require-wp-5.5 Scenario: The fields can be shown individually Given I run `wp plugin auto-updates enable hello` @@ -106,7 +89,6 @@ Feature: Show the status of auto-updates for WordPress plugins Then STDOUT should be: """ akismet - sqlite-database-integration duplicate-post """ @@ -116,7 +98,7 @@ Feature: Show the status of auto-updates for WordPress plugins enabled """ - @require-wp-5.5 @require-mysql + @require-wp-5.5 Scenario: Formatting options work When I run `wp plugin auto-updates status --all --format=json` Then STDOUT should be: @@ -132,21 +114,3 @@ Feature: Show the status of auto-updates for WordPress plugins hello,disabled duplicate-post,disabled """ - - @require-wp-5.5 @require-sqlite - Scenario: Formatting options work - When I run `wp plugin auto-updates status --all --format=json` - Then STDOUT should be: - """ - [{"name":"akismet","status":"disabled"},{"name":"hello","status":"disabled"},{"name":"sqlite-database-integration","status":"disabled"},{"name":"duplicate-post","status":"disabled"}] - """ - - When I run `wp plugin auto-updates status --all --format=csv` - Then STDOUT should be: - """ - name,status - akismet,disabled - hello,disabled - sqlite-database-integration,disabled - duplicate-post,disabled - """ diff --git a/features/plugin-delete.feature b/features/plugin-delete.feature index af1e1c7d..8fc3cc9d 100644 --- a/features/plugin-delete.feature +++ b/features/plugin-delete.feature @@ -12,7 +12,6 @@ Feature: Delete WordPress plugins """ And the return code should be 0 - @require-mysql Scenario: Delete all installed plugins When I run `wp plugin delete --all` Then STDOUT should be: @@ -29,24 +28,6 @@ Feature: Delete WordPress plugins Success: No plugins deleted. """ - @require-sqlite - Scenario: Delete all installed plugins - When I run `wp plugin delete --all` - Then STDOUT should be: - """ - Deleted 'akismet' plugin. - Deleted 'hello' plugin. - Deleted 'sqlite-database-integration' plugin. - Success: Deleted 3 of 3 plugins. - """ - And the return code should be 0 - - When I run the previous command again - Then STDOUT should be: - """ - Success: No plugins deleted. - """ - Scenario: Attempting to delete a plugin that doesn't exist When I try `wp plugin delete edit-flow` Then STDOUT should be: @@ -59,7 +40,6 @@ Feature: Delete WordPress plugins """ And the return code should be 0 - @require-mysql Scenario: Excluding a plugin from deletion when using --all switch When I try `wp plugin delete --all --exclude=akismet,hello` Then STDOUT should be: @@ -68,15 +48,6 @@ Feature: Delete WordPress plugins """ And the return code should be 0 - @require-sqlite - Scenario: Excluding a plugin from deletion when using --all switch - When I try `wp plugin delete --all --exclude=akismet,hello,sqlite-database-integration` - Then STDOUT should be: - """ - Success: No plugins deleted. - """ - And the return code should be 0 - Scenario: Excluding a missing plugin should not throw an error Given a WP install And I run `wp plugin delete --all --exclude=missing-plugin` diff --git a/features/plugin-uninstall.feature b/features/plugin-uninstall.feature index b224fc6d..c43f527b 100644 --- a/features/plugin-uninstall.feature +++ b/features/plugin-uninstall.feature @@ -72,7 +72,6 @@ Feature: Uninstall a WordPress plugin Success: Uninstalled 2 of 2 plugins. """ - @require-mysql Scenario: Excluding a plugin from uninstallation when using --all switch When I try `wp plugin uninstall --all --exclude=akismet,hello` Then STDOUT should be: @@ -81,15 +80,6 @@ Feature: Uninstall a WordPress plugin """ And the return code should be 0 - @require-sqlite - Scenario: Excluding a plugin from uninstallation when using --all switch - When I try `wp plugin uninstall --all --exclude=akismet,hello,sqlite-database-integration` - Then STDOUT should be: - """ - Success: No plugins uninstalled. - """ - And the return code should be 0 - Scenario: Excluding a missing plugin should not throw an error Given a WP install And I run `wp plugin uninstall --all --exclude=missing-plugin` diff --git a/features/plugin-update.feature b/features/plugin-update.feature index 398629bb..2f17974f 100644 --- a/features/plugin-update.feature +++ b/features/plugin-update.feature @@ -13,8 +13,8 @@ Feature: Update WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | wordpress-importer | inactive | available | 0.5 | + | name | status | update | version | auto_update | + | wordpress-importer | inactive | available | 0.5 | off | When I try `wp plugin update akismet --version=0.5.3` Then STDERR should be: @@ -25,16 +25,16 @@ Feature: Update WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | wordpress-importer | inactive | available | 0.5 | + | name | status | update | version | auto_update | + | wordpress-importer | inactive | available | 0.5 | off | When I run `wp plugin update wordpress-importer` Then STDOUT should not be empty When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | wordpress-importer | inactive | none | {UPDATE_VERSION} | + | name | status | update | version | auto_update | + | wordpress-importer | inactive | none | {UPDATE_VERSION} | off | Scenario: Error when both --minor and --patch are provided Given a WP install diff --git a/features/plugin.feature b/features/plugin.feature index 26d923c3..3d89d976 100644 --- a/features/plugin.feature +++ b/features/plugin.feature @@ -63,8 +63,8 @@ Feature: Manage WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | Zombieland | active | none | 0.1.0 | + | name | status | update | version | auto_update | + | Zombieland | active | none | 0.1.0 | off | When I try `wp plugin uninstall Zombieland` Then STDERR should be: @@ -131,8 +131,8 @@ Feature: Manage WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | wordpress-importer | active | available | 0.5 | + | name | status | update | version | auto_update | + | wordpress-importer | active | available | 0.5 | off | When I try `wp plugin update` Then STDERR should be: @@ -397,11 +397,13 @@ Feature: Manage WordPress plugins Installing Debug Bar List Script & Style Dependencies """ + # Not running for SQLite because it involves another must-use plugin and a drop-in. + @require-mysql Scenario: Enable and disable all plugins Given a WP install When I run `wp plugin activate --all` - Then STDOUT should be: + Then STDOUT should contain: """ Plugin 'akismet' activated. Plugin 'hello' activated. @@ -651,8 +653,8 @@ Feature: Manage WordPress plugins When I run `wp plugin list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} | + | name | status | update | version | auto_update | + | hello-dolly | inactive | version higher than expected | {PLUGIN_VERSION} | off | When I try `wp plugin update --all` Then STDERR should be: diff --git a/features/theme.feature b/features/theme.feature index 0c9235b9..2e98631f 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -79,8 +79,8 @@ Feature: Manage WordPress themes When I run `wp theme list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | p2 | inactive | available | 1.4.2 | + | name | status | update | version | auto_update | + | p2 | inactive | available | 1.4.2 | off | When I run `wp theme activate p2` Then STDOUT should not be empty @@ -97,8 +97,8 @@ Feature: Manage WordPress themes When I run `wp theme list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | p2 | active | available | 1.4.1 | + | name | status | update | version | auto_update | + | p2 | active | available | 1.4.1 | off | When I try `wp theme update` Then STDERR should be: @@ -388,8 +388,8 @@ Feature: Manage WordPress themes When I try `wp theme list --fields=name,status` Then STDOUT should be a table containing rows: | name | status | - | moina-blog | active | - | moina | parent | + | moina-blog | active | + | moina | parent | Scenario: When updating a theme --format should be the same when using --dry-run Given a WP install diff --git a/features/upgradables.feature b/features/upgradables.feature index d4445d47..2c5f9fec 100644 --- a/features/upgradables.feature +++ b/features/upgradables.feature @@ -53,8 +53,8 @@ Feature: Manage WordPress themes and plugins When I run `wp list` Then STDOUT should be a table containing rows: - | name | status | update | version | - | | inactive | available | | + | name | status | update | version | auto_update | + | | inactive | available | | off | When I run `wp list --field=name` Then STDOUT should contain: @@ -203,6 +203,6 @@ Feature: Manage WordPress themes and plugins And the return code should be 1 Examples: - | type | type_name | item | item_title | version | zip_file | file_to_check | + | type | type_name | item | item_title | version | zip_file | file_to_check | | theme | Theme | p2 | P2 | 1.0.1 | https://wordpress.org/themes/download/p2.1.0.1.zip | {CONTENT_DIR}/p2/style.css | | plugin | Plugin | category-checklist-tree | Category Checklist Tree | 1.2 | https://downloads.wordpress.org/plugin/category-checklist-tree.1.2.zip | {CONTENT_DIR}/category-checklist-tree/category-checklist-tree.php | diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 7461b1fb..235bbe58 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -52,6 +52,7 @@ class Plugin_Command extends \WP_CLI\CommandWithUpgrade { 'status', 'update', 'version', + 'auto_update', ); /** diff --git a/src/Theme_Command.php b/src/Theme_Command.php index 225656b6..4470b7cb 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -49,7 +49,13 @@ class Theme_Command extends CommandWithUpgrade { protected $upgrade_refresh = 'wp_update_themes'; protected $upgrade_transient = 'update_themes'; - protected $obj_fields = [ 'name', 'status', 'update', 'version' ]; + protected $obj_fields = [ + 'name', + 'status', + 'update', + 'version', + 'auto_update', + ]; public function __construct() { if ( is_multisite() ) {