-
Notifications
You must be signed in to change notification settings - Fork 87
Add --force-check
flag to wp plugin list
and wp theme list
.
#426
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
Closed
baizmandesign
wants to merge
10
commits into
wp-cli:main
from
baizmandesign:feature/plugin-theme-force-check-183
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2020056
Add —force-check flag to wp plugin list and wp theme list. (wip)
baizmandesign f5101e4
Refactor Behat tests
danielbachhuber a0ad195
Actually delete the correct upgrade transient
danielbachhuber c815ae4
Add test for the simultaneous presence of `--force-check` and `--skip…
baizmandesign 50c4a75
Add another test to plugin-list.feature.
baizmandesign 58db5c9
Revise the tests in theme-list.feature.
baizmandesign 3c853c9
Modified files to respond to @ernilambar’s feedback.
baizmandesign 9091c32
Update the plugin-list.feature to more closely copy theme-list.feature.
baizmandesign 9c85840
Add uppercase first word warning.
baizmandesign 069bbb5
Merge branch 'main' into feature/plugin-theme-force-check-183
swissspidy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Feature: List WordPress plugins | ||
|
||
Scenario: Refresh update_plugins transient when listing plugins with --force-check flag | ||
Given a WP install | ||
And I run `wp plugin uninstall --all` | ||
And I run `wp plugin install hello-dolly` | ||
And a update-transient.php file: | ||
""" | ||
<?php | ||
$transient = get_site_transient( 'update_plugins' ); | ||
$transient->response['hello-dolly/hello.php'] = (object) array( | ||
'id' => 'w.org/plugins/hello-dolly', | ||
'slug' => 'hello-dolly', | ||
'plugin' => 'hello-dolly/hello.php', | ||
'new_version' => '100.0.0', | ||
'url' => 'https://wordpress.org/plugins/hello-dolly/', | ||
'package' => 'https://downloads.wordpress.org/plugin/hello-dolly.100.0.0.zip', | ||
); | ||
$transient->checked = array( | ||
'hello-dolly/hello.php' => '1.7.2', | ||
); | ||
unset( $transient->no_update['hello-dolly/hello.php'] ); | ||
set_site_transient( 'update_plugins', $transient ); | ||
WP_CLI::success( 'Transient updated.' ); | ||
""" | ||
|
||
# Populates the initial transient in the database | ||
When I run `wp plugin list --fields=name,status,update` | ||
Then STDOUT should be a table containing rows: | ||
| name | status | update | | ||
| hello-dolly | inactive | none | | ||
|
||
# Modify the transient in the database to simulate an update | ||
When I run `wp eval-file update-transient.php` | ||
Then STDOUT should be: | ||
""" | ||
Success: Transient updated. | ||
""" | ||
|
||
# Verify the fake transient value produces the expected output | ||
When I run `wp plugin list --fields=name,status,update` | ||
Then STDOUT should be a table containing rows: | ||
| name | status | update | | ||
| hello-dolly | inactive | available | | ||
|
||
# Repeating the same command again should produce the same results | ||
When I run the previous command again | ||
Then STDOUT should be a table containing rows: | ||
| name | status | update | | ||
| hello-dolly | inactive | available | | ||
|
||
# Using the --force-check flag should refresh the transient back to the original value | ||
When I run `wp plugin list --fields=name,status,update --force-check` | ||
Then STDOUT should be a table containing rows: | ||
| name | status | update | | ||
| hello-dolly | inactive | none | | ||
|
||
When I try `wp plugin list --skip-update-check --force-check` | ||
Then STDERR should contain: | ||
""" | ||
Error: Plugin updates cannot be both force-checked and skipped. Choose one. | ||
""" | ||
And STDOUT should be empty | ||
And the return code should be 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Feature: List WordPress themes | ||
|
||
Scenario: Refresh update_themes transient when listing themes with --force-check flag | ||
Given a WP install | ||
And I run `wp theme delete --all --force` | ||
And I run `wp theme install --force twentytwelve --version=4.2` | ||
And a update-transient.php file: | ||
""" | ||
<?php | ||
$transient = get_site_transient( 'update_themes' ); | ||
$transient->response['twentytwelve'] = (object) array( | ||
'theme' => 'twentytwelve', | ||
'new_version' => '100.0.0', | ||
'url' => 'https://wordpress.org/themes/twentytwelve/', | ||
'package' => 'https://downloads.wordpress.org/theme/twentytwelve.100.zip' | ||
); | ||
$transient->checked = array( | ||
'twentytwelve' => '4.2', | ||
); | ||
unset( $transient->no_update['twentytwelve'] ); | ||
set_site_transient( 'update_themes', $transient ); | ||
WP_CLI::success( 'Transient updated.' ); | ||
""" | ||
|
||
# Populates the initial transient in the database | ||
When I run `wp theme list --fields=name,update` | ||
Then STDOUT should be a table containing rows: | ||
| name | update | | ||
| twentytwelve | none | | ||
|
||
# Modify the transient in the database to simulate an update | ||
When I run `wp eval-file update-transient.php` | ||
Then STDOUT should be: | ||
""" | ||
Success: Transient updated. | ||
""" | ||
|
||
# Verify the fake transient value produces the expected output | ||
When I run `wp theme list --fields=name,update` | ||
Then STDOUT should be a table containing rows: | ||
| name | update | | ||
| twentytwelve | available | | ||
|
||
# Repeating the same command again should produce the same results | ||
When I run the previous command again | ||
Then STDOUT should be a table containing rows: | ||
| name | update | | ||
| twentytwelve | available | | ||
|
||
# Using the --force-check flag should refresh the transient back to the original value | ||
When I run `wp theme list --fields=name,update --force-check` | ||
Then STDOUT should be a table containing rows: | ||
| name | update | | ||
| twentytwelve | none | | ||
|
||
When I try `wp theme list --skip-update-check --force-check` | ||
Then STDERR should contain: | ||
""" | ||
Error: Theme updates cannot be both force-checked and skipped. Choose one. | ||
""" | ||
And STDOUT should be empty | ||
And the return code should be 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.