mirror of
https://gh.wpcy.net/https://github.com/wp-cli/extension-command.git
synced 2026-06-11 01:53:58 +08:00
* Initial plan * Add VCS checkout detection for plugin/theme updates with --include-vcs flag Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> Co-authored-by: Pascal Birchler <pascalb@google.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
290 lines
8.9 KiB
Gherkin
290 lines
8.9 KiB
Gherkin
Feature: Update WordPress themes
|
|
|
|
Scenario: Updating a theme with no version in the WordPress.org directory shouldn't delete the original theme
|
|
Given a WP install
|
|
|
|
When I run `wp theme install twentytwelve --force`
|
|
And I run `wp scaffold child-theme wpclitesttheme --parent_theme=twentytwelve`
|
|
Then the wp-content/themes/wpclitesttheme directory should exist
|
|
|
|
When I try `wp theme update wpclitesttheme --version=100.0.0`
|
|
Then STDERR should contain:
|
|
"""
|
|
Error: No themes installed
|
|
"""
|
|
And the wp-content/themes/wpclitesttheme directory should exist
|
|
|
|
Scenario: Install a theme, then update to a specific version of that theme
|
|
Given a WP install
|
|
And I run `wp theme delete --all --force`
|
|
|
|
When I run `wp theme install twentytwelve --version=3.0`
|
|
Then STDOUT should not be empty
|
|
|
|
When I run `wp theme update twentytwelve --version=4.0`
|
|
Then STDOUT should not be empty
|
|
|
|
When I run `wp theme list --fields=name,version`
|
|
Then STDOUT should be a table containing rows:
|
|
| name | version |
|
|
| twentytwelve | 4.0 |
|
|
|
|
@require-wp-4.5
|
|
Scenario: Not giving a slug on update should throw an error unless --all given
|
|
Given a WP install
|
|
And I run `wp theme path`
|
|
And save STDOUT as {THEME_DIR}
|
|
And an empty {THEME_DIR} directory
|
|
|
|
# No themes installed. Don't give an error if --all given for BC.
|
|
When I run `wp theme update --all`
|
|
Then STDOUT should be:
|
|
"""
|
|
Success: No themes installed.
|
|
"""
|
|
|
|
When I run `wp theme update --version=0.6 --all`
|
|
Then STDOUT should be:
|
|
"""
|
|
Success: No themes installed.
|
|
"""
|
|
|
|
# One theme installed.
|
|
Given I run `wp theme install moina --version=1.0.2`
|
|
|
|
When I try `wp theme update`
|
|
Then the return code should be 1
|
|
And STDERR should be:
|
|
"""
|
|
Error: Please specify one or more themes, or use --all.
|
|
"""
|
|
And STDOUT should be empty
|
|
|
|
When I run `wp theme update --all`
|
|
Then STDOUT should contain:
|
|
"""
|
|
Success: Updated
|
|
"""
|
|
|
|
When I run the previous command again
|
|
Then STDOUT should be:
|
|
"""
|
|
Success: Theme already updated.
|
|
"""
|
|
|
|
# Note: if given version then re-installs.
|
|
When I run `wp theme update --version=1.0.2 --all`
|
|
Then STDOUT should contain:
|
|
"""
|
|
Success: Installed 1 of 1 themes.
|
|
"""
|
|
|
|
When I run the previous command again
|
|
Then STDOUT should contain:
|
|
"""
|
|
Success: Installed 1 of 1 themes.
|
|
"""
|
|
|
|
# Two themes installed.
|
|
Given I run `wp theme install --force twentytwelve --version=1.0`
|
|
|
|
When I run `wp theme update --all`
|
|
Then STDOUT should contain:
|
|
"""
|
|
Success: Updated
|
|
"""
|
|
|
|
When I run the previous command again
|
|
# BUG: Message should be in plural.
|
|
Then STDOUT should be:
|
|
"""
|
|
Success: Theme already updated.
|
|
"""
|
|
|
|
# Using version with all rarely makes sense and should probably error and do nothing.
|
|
When I try `wp theme update --version=1.0.3 --all`
|
|
Then the return code should be 1
|
|
And STDOUT should contain:
|
|
"""
|
|
Success: Installed 1 of 1 themes.
|
|
"""
|
|
And STDERR should be:
|
|
"""
|
|
Error: Can't find the requested theme's version 1.0.3 in the WordPress.org theme repository (HTTP code 404).
|
|
"""
|
|
|
|
Scenario: Error when both --minor and --patch are provided
|
|
Given a WP install
|
|
|
|
When I try `wp theme update --patch --minor --all`
|
|
Then STDERR should be:
|
|
"""
|
|
Error: --minor and --patch cannot be used together.
|
|
"""
|
|
And the return code should be 1
|
|
|
|
Scenario: Update a theme to its latest minor release
|
|
Given a WP install
|
|
And I run `wp theme install --force twentytwelve --version=3.0`
|
|
|
|
When I run `wp theme update twentytwelve --minor`
|
|
Then STDOUT should contain:
|
|
"""
|
|
Success: Updated 1 of 1 themes.
|
|
"""
|
|
|
|
When I run `wp theme get twentytwelve --field=version`
|
|
Then STDOUT should be:
|
|
"""
|
|
3.9
|
|
"""
|
|
|
|
Scenario: Update a theme to its latest patch release
|
|
Given a WP install
|
|
And I run `wp theme install --force twentytwelve --version=1.1`
|
|
|
|
When I run `wp theme update twentytwelve --patch`
|
|
Then STDOUT should contain:
|
|
"""
|
|
Success: Updated 1 of 1 themes.
|
|
"""
|
|
|
|
When I run `wp theme get twentytwelve --field=version`
|
|
Then STDOUT should be:
|
|
"""
|
|
1.1.1
|
|
"""
|
|
|
|
# Tests for --auto-update-indicated feature
|
|
# Note: These tests verify the flag handling and error cases.
|
|
# The actual update behavior when autoupdate is true from the server
|
|
# cannot be easily tested as it requires mocking WordPress.org API responses.
|
|
# The update functionality itself is handled by the existing update_many method.
|
|
|
|
Scenario: Show auto_update_indicated field in theme list
|
|
Given a WP install
|
|
|
|
When I run `wp theme install twentytwelve --version=3.0 --force`
|
|
Then STDOUT should not be empty
|
|
|
|
When I run `wp theme list --fields=name,version,update,auto_update_indicated`
|
|
Then STDOUT should be a table containing rows:
|
|
| name | version | update | auto_update_indicated |
|
|
| twentytwelve | 3.0 | available | no |
|
|
|
|
Scenario: Using --auto-update-indicated flag when no themes have auto-update indicated
|
|
Given a WP install
|
|
|
|
When I run `wp theme install twentytwelve --version=3.0 --force`
|
|
Then STDOUT should not be empty
|
|
|
|
When I run `wp theme update --auto-update-indicated`
|
|
Then STDOUT should be:
|
|
"""
|
|
Success: No themes with server-indicated automatic updates available.
|
|
"""
|
|
|
|
Scenario: Error when using --version with --auto-update-indicated
|
|
Given a WP install
|
|
|
|
When I try `wp theme update --auto-update-indicated --version=1.0.0`
|
|
Then STDERR should be:
|
|
"""
|
|
Error: Cannot use --version with --auto-update-indicated. The version is determined by the server.
|
|
"""
|
|
And the return code should be 1
|
|
|
|
Scenario: Error when using --minor with --auto-update-indicated
|
|
Given a WP install
|
|
|
|
When I try `wp theme update --auto-update-indicated --minor`
|
|
Then STDERR should be:
|
|
"""
|
|
Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.
|
|
"""
|
|
And the return code should be 1
|
|
|
|
Scenario: Error when using --patch with --auto-update-indicated
|
|
Given a WP install
|
|
|
|
When I try `wp theme update --auto-update-indicated --patch`
|
|
Then STDERR should be:
|
|
"""
|
|
Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.
|
|
"""
|
|
And the return code should be 1
|
|
|
|
Scenario: Error when specifying theme names with --auto-update-indicated
|
|
Given a WP install
|
|
|
|
When I try `wp theme update twentytwelve --auto-update-indicated`
|
|
Then STDERR should be:
|
|
"""
|
|
Error: Cannot specify theme names with --auto-update-indicated. This flag updates all themes with server-indicated automatic updates.
|
|
"""
|
|
And the return code should be 1
|
|
|
|
Scenario: Preview updates with --auto-update-indicated and --dry-run
|
|
Given a WP install
|
|
|
|
When I run `wp theme install twentytwelve --version=3.0 --force`
|
|
Then STDOUT should not be empty
|
|
|
|
When I run `wp theme update --auto-update-indicated --dry-run`
|
|
Then STDOUT should be:
|
|
"""
|
|
Success: No themes with server-indicated automatic updates available.
|
|
"""
|
|
|
|
@require-wp-4.5
|
|
Scenario: Updating all themes should show the name of each theme as it is updated
|
|
Given a WP install
|
|
And I run `wp theme delete --all --force`
|
|
|
|
When I run `wp theme install moina --version=1.0.2`
|
|
Then STDOUT should not be empty
|
|
|
|
When I run `wp theme install twentytwelve --version=1.0`
|
|
Then STDOUT should not be empty
|
|
|
|
When I try `wp theme update --all`
|
|
Then STDOUT should contain:
|
|
"""
|
|
Updating Moina...
|
|
"""
|
|
|
|
And STDOUT should contain:
|
|
"""
|
|
Success: Updated 2 of 2 themes.
|
|
"""
|
|
|
|
Scenario: Skip theme update when theme directory is a VCS checkout
|
|
Given a WP install
|
|
And I run `wp theme install twentytwelve --version=3.0 --force`
|
|
And I run `wp theme path twentytwelve --dir`
|
|
And save STDOUT as {THEME_DIR}
|
|
|
|
When I run `mkdir {THEME_DIR}/.git`
|
|
And I try `wp theme update twentytwelve`
|
|
Then STDERR should contain:
|
|
"""
|
|
Warning: twentytwelve: Skipped update because a VCS checkout was detected. Use --include-vcs to override.
|
|
"""
|
|
And STDERR should contain:
|
|
"""
|
|
Error: No themes updated.
|
|
"""
|
|
And the return code should be 1
|
|
|
|
Scenario: Update theme in VCS checkout when --include-vcs is set
|
|
Given a WP install
|
|
And I run `wp theme install twentytwelve --version=3.0 --force`
|
|
And I run `wp theme path twentytwelve --dir`
|
|
And save STDOUT as {THEME_DIR}
|
|
|
|
When I run `mkdir {THEME_DIR}/.git`
|
|
And I run `wp theme update twentytwelve --include-vcs`
|
|
Then STDOUT should contain:
|
|
"""
|
|
Success: Updated 1 of 1 themes.
|
|
"""
|