Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
30 changes: 30 additions & 0 deletions extension-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,33 @@
WP_CLI::add_command( 'theme', 'Theme_Command' );
WP_CLI::add_command( 'theme auto-updates', 'Theme_AutoUpdates_Command', $wpcli_extension_requires_wp_5_5 );
WP_CLI::add_command( 'theme mod', 'Theme_Mod_Command' );

// In admin context, WordPress hooks wp_update_plugins/wp_update_themes to
// various actions, causing update checks to run even when --skip-update-check is passed.

WP_CLI::add_hook(
'before_wp_load',
static function () {
if ( ! \WP_CLI\Utils\get_flag_value( WP_CLI::get_runner()->assoc_args, 'skip-update-check' ) ) {
return;
}

WP_CLI::add_wp_hook(
'wp_loaded',
static function () {
remove_action( 'load-plugins.php', 'wp_update_plugins' );
remove_action( 'load-update.php', 'wp_update_plugins' );
remove_action( 'load-update-core.php', 'wp_update_plugins' );
remove_action( 'admin_init', '_maybe_update_plugins' );
remove_action( 'wp_update_plugins', 'wp_update_plugins' );

remove_action( 'load-themes.php', 'wp_update_themes' );
remove_action( 'load-update.php', 'wp_update_themes' );
remove_action( 'load-update-core.php', 'wp_update_themes' );
remove_action( 'admin_init', '_maybe_update_themes' );
remove_action( 'wp_update_themes', 'wp_update_themes' );
},
PHP_INT_MIN
);
}
);
6 changes: 3 additions & 3 deletions features/plugin-auto-updates-disable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: Disable auto-updates for WordPress plugins

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

@require-wp-5.5
Expand All @@ -25,7 +25,7 @@ Feature: Disable auto-updates for WordPress plugins

@require-wp-5.5
Scenario: Disable auto-updates for multiple plugins
When I run `wp plugin auto-updates disable sample-plugin duplicate-post`
When I run `wp plugin auto-updates disable sample-plugin debug-bar`
Then STDOUT should be:
"""
Success: Disabled 2 of 2 plugin auto-updates.
Expand Down Expand Up @@ -73,7 +73,7 @@ Feature: Disable auto-updates for WordPress plugins
@require-wp-5.5
Scenario: Filter when disabling auto-updates for already disabled selection of plugins
When I run `wp plugin auto-updates disable sample-plugin`
And I run `wp plugin auto-updates disable sample-plugin duplicate-post --enabled-only`
And I run `wp plugin auto-updates disable sample-plugin debug-bar --enabled-only`
Then STDOUT should be:
"""
Success: Disabled 1 of 1 plugin auto-updates.
Expand Down
6 changes: 3 additions & 3 deletions features/plugin-auto-updates-enable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: Enable auto-updates for WordPress plugins

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

@require-wp-5.5
Scenario: Show an error if required params are missing
Expand All @@ -24,7 +24,7 @@ Feature: Enable auto-updates for WordPress plugins

@require-wp-5.5
Scenario: Enable auto-updates for multiple plugins
When I run `wp plugin auto-updates enable sample-plugin duplicate-post`
When I run `wp plugin auto-updates enable sample-plugin debug-bar`
Then STDOUT should be:
"""
Success: Enabled 2 of 2 plugin auto-updates.
Expand Down Expand Up @@ -72,7 +72,7 @@ Feature: Enable auto-updates for WordPress plugins
@require-wp-5.5
Scenario: Filter when enabling auto-updates for already enabled selection of plugins
When I run `wp plugin auto-updates enable sample-plugin`
And I run `wp plugin auto-updates enable sample-plugin duplicate-post --disabled-only`
And I run `wp plugin auto-updates enable sample-plugin debug-bar --disabled-only`
Then STDOUT should be:
"""
Success: Enabled 1 of 1 plugin auto-updates.
Expand Down
20 changes: 10 additions & 10 deletions features/plugin-auto-updates-status.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Feature: Show the status of auto-updates for WordPress plugins

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

@require-wp-5.5
Scenario: Show an error if required params are missing
Expand All @@ -23,10 +23,10 @@ Feature: Show the status of auto-updates for WordPress plugins

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

Expand All @@ -36,7 +36,7 @@ Feature: Show the status of auto-updates for WordPress plugins
Then STDOUT should be a table containing rows:
| name | status |
| akismet | disabled |
| duplicate-post | disabled |
| debug-bar | disabled |
| sample-plugin | disabled |
And the return code should be 0

Expand All @@ -45,7 +45,7 @@ Feature: Show the status of auto-updates for WordPress plugins
Then STDOUT should be a table containing rows:
| name | status |
| akismet | enabled |
| duplicate-post | enabled |
| debug-bar | enabled |
| sample-plugin | enabled |
And the return code should be 0

Expand All @@ -57,7 +57,7 @@ Feature: Show the status of auto-updates for WordPress plugins
Then STDOUT should be a table containing rows:
| name | status |
| akismet | disabled |
| duplicate-post | disabled |
| debug-bar | disabled |
| sample-plugin | enabled |
And the return code should be 0

Expand All @@ -71,7 +71,7 @@ Feature: Show the status of auto-updates for WordPress plugins
Then STDOUT should be a table containing rows:
| name | status |
| akismet | disabled |
| duplicate-post | disabled |
| debug-bar | disabled |
And the return code should be 0

When I try `wp plugin auto-updates status --all --enabled-only --disabled-only`
Expand All @@ -92,7 +92,7 @@ Feature: Show the status of auto-updates for WordPress plugins
"""
And STDOUT should contain:
"""
duplicate-post
debug-bar
"""

When I run `wp plugin auto-updates status sample-plugin --field=status`
Expand All @@ -114,7 +114,7 @@ Feature: Show the status of auto-updates for WordPress plugins
"""
And STDOUT should contain:
"""
{"name":"duplicate-post","status":"disabled"}
{"name":"debug-bar","status":"disabled"}
"""

When I run `wp plugin auto-updates status --all --format=csv`
Expand All @@ -128,7 +128,7 @@ Feature: Show the status of auto-updates for WordPress plugins
"""
And STDOUT should contain:
"""
duplicate-post,disabled
debug-bar,disabled
"""

@require-wp-5.5
Expand Down
9 changes: 5 additions & 4 deletions features/plugin-dependencies.feature
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Feature: Plugin dependencies support
<?php
/**
* Plugin Name: Test Plugin
* Requires Plugins: duplicate-post, debug-bar
* Requires Plugins: debug-bar, disable-embeds
*/
"""

Expand All @@ -75,13 +75,13 @@ Feature: Plugin dependencies support
Success:
"""

When I run `wp plugin list --name=duplicate-post --field=status`
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
inactive
"""

When I run `wp plugin list --name=debug-bar --field=status`
When I run `wp plugin list --name=disable-embeds --field=status`
Then STDOUT should be:
"""
inactive
Expand Down Expand Up @@ -119,7 +119,8 @@ Feature: Plugin dependencies support
Warning: akismet: Plugin already installed.
"""

When I run `wp plugin list --fields=name,status --format=csv`
# Expecting a warning for BuddyPress attempting a redirect upon activation.
When I try `wp plugin list --fields=name,status --format=csv`
Then STDOUT should contain:
"""
buddypress,active
Expand Down
48 changes: 26 additions & 22 deletions features/plugin-install.feature
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ Feature: Install WordPress plugins
"""
Warning: Plugin already installed.
"""
And STDERR should not contain:
"""
plugin could not be found
"""
And STDOUT should contain:
"""
Success: Plugin already installed.
Expand Down Expand Up @@ -371,14 +375,14 @@ Feature: Install WordPress plugins
Scenario: Install plugin using WordPress.org directory URL
Given a WP install

When I run `wp plugin install https://wordpress.org/plugins/hello-dolly/`
When I run `wp plugin install https://wordpress.org/plugins/debug-bar/`
Then STDOUT should contain:
"""
Detected WordPress.org plugins directory URL, using slug: hello-dolly
Detected WordPress.org plugins directory URL, using slug: debug-bar
"""
And the return code should be 0

When I run `wp plugin list --name=hello-dolly --field=status`
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
inactive
Expand All @@ -387,14 +391,14 @@ Feature: Install WordPress plugins
Scenario: Install and activate plugin using WordPress.org directory URL
Given a WP install

When I run `wp plugin install https://wordpress.org/plugins/hello-dolly/ --activate`
When I run `wp plugin install https://wordpress.org/plugins/debug-bar/ --activate`
Then STDOUT should contain:
"""
Detected WordPress.org plugins directory URL, using slug: hello-dolly
Detected WordPress.org plugins directory URL, using slug: debug-bar
"""
And the return code should be 0

When I run `wp plugin list --name=hello-dolly --field=status`
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active
Expand All @@ -403,35 +407,35 @@ Feature: Install WordPress plugins
Scenario: Install with --activate on already-active plugin should keep it activated
Given a WP install

When I run `wp plugin install hello-dolly --activate`
When I run `wp plugin install debug-bar --activate`
Then STDOUT should contain:
"""
Plugin 'hello-dolly' activated.
Plugin 'debug-bar' activated.
"""
And the return code should be 0

When I run `wp plugin list --name=hello-dolly --field=status`
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active
"""

When I try `wp plugin install hello-dolly --activate`
When I try `wp plugin install debug-bar --activate`
Then STDERR should contain:
"""
Warning: hello-dolly: Plugin already installed.
Warning: debug-bar: Plugin already installed.
"""
And STDOUT should contain:
"""
Activating 'hello-dolly'...
Activating 'debug-bar'...
"""
And STDOUT should contain:
"""
Plugin 'hello-dolly' activated.
Plugin 'debug-bar' activated.
"""
And the return code should be 0

When I run `wp plugin list --name=hello-dolly --field=status`
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active
Expand All @@ -440,35 +444,35 @@ Feature: Install WordPress plugins
Scenario: Install with --activate-network on already-network-active plugin should keep it activated
Given a WP multisite install

When I run `wp plugin install hello-dolly --activate-network`
When I run `wp plugin install debug-bar --activate-network`
Then STDOUT should contain:
"""
Plugin 'hello-dolly' network activated.
Plugin 'debug-bar' network activated.
"""
And the return code should be 0

When I run `wp plugin list --name=hello-dolly --field=status`
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active-network
"""

When I try `wp plugin install hello-dolly --activate-network`
When I try `wp plugin install debug-bar --activate-network`
Then STDERR should contain:
"""
Warning: hello-dolly: Plugin already installed.
Warning: debug-bar: Plugin already installed.
"""
And STDOUT should contain:
"""
Network-activating 'hello-dolly'...
Network-activating 'debug-bar'...
"""
And STDOUT should contain:
"""
Plugin 'hello-dolly' network activated.
Plugin 'debug-bar' network activated.
"""
And the return code should be 0

When I run `wp plugin list --name=hello-dolly --field=status`
When I run `wp plugin list --name=debug-bar --field=status`
Then STDOUT should be:
"""
active-network
Expand Down
2 changes: 1 addition & 1 deletion features/plugin-search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Feature: Search WordPress.org plugins
Scenario: Search for plugins with url field
Given a WP install

When I run `wp plugin search gutenberg --fields=slug,url --format=csv`
When I run `wp plugin search gutenberg --fields=slug,url --format=csv --per-page=20`
Then STDOUT should contain:
"""
gutenberg,https://wordpress.org/plugins/gutenberg/
Expand Down
8 changes: 6 additions & 2 deletions features/plugin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,12 @@ Feature: Manage WordPress plugins
Success: Transient deleted.
"""

When I run `wp plugin list --fields=name,status,update --status=inactive --skip-update-check`
Then STDOUT should be a table containing rows:
When I run `wp plugin list --fields=name,status,update --status=inactive --skip-update-check --debug=http`
Then STDERR should not contain:
"""
HTTP POST request to https://api.wordpress.org/plugins/update-check
"""
And STDOUT should be a table containing rows:
| name | status | update |
| wordpress-importer | inactive | none |

Expand Down
8 changes: 6 additions & 2 deletions features/theme.feature
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,12 @@ Feature: Manage WordPress themes
Success: Transient deleted.
"""

When I run `wp theme list --fields=name,status,update --skip-update-check`
Then STDOUT should be a table containing rows:
When I run `wp theme list --fields=name,status,update --skip-update-check --debug=http`
Then STDERR should not contain:
"""
HTTP POST request to https://api.wordpress.org/themes/update-check
"""
And STDOUT should be a table containing rows:
| name | status | update |
| astra | inactive | none |

Expand Down
Loading