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
22 changes: 22 additions & 0 deletions features/package-update.feature
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ Feature: Update WP-CLI packages
| name | update |
| wp-cli-test/updateable-package | none |

Scenario: Update a package named more than once counts it once
Given an empty directory

When I run `wp package install wp-cli-test/updateable-package:v3.0.0`
Then STDOUT should contain:
"""
Success: Package installed.
"""

When I run `wp eval "file_put_contents( '{PACKAGE_PATH}composer.json', str_replace( 'v3.0.0', '>=3.0.0', file_get_contents( '{PACKAGE_PATH}composer.json' ) ) );" --skip-wordpress`
Then the return code should be 0

When I run `wp package update wp-cli-test/updateable-package wp-cli-test/updateable-package`
Then STDOUT should contain:
"""
Success: Package updated successfully.
"""
And STDOUT should not contain:
"""
All 2 packages
"""

Scenario: Update multiple specific packages by name
Given an empty directory

Expand Down
3 changes: 2 additions & 1 deletion src/Package_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,8 @@ public function update( $args, $assoc_args = [] ) {
// Validate package names if provided
$packages_to_update = [];
if ( ! empty( $args ) ) {
foreach ( $args as $package_name ) {
// Look up and report each package once, even if it was named more than once.
foreach ( array_unique( $args ) as $package_name ) {
$package = $this->get_installed_package_by_name( $package_name );
if ( false === $package ) {
WP_CLI::error( sprintf( "Package '%s' is not installed.", $package_name ) );
Expand Down