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
48 changes: 48 additions & 0 deletions features/package-install.feature
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,54 @@ Feature: Install WP-CLI packages
wp-cli/google-sitemap-generator-cli
"""

@github-api
Scenario: Install a package from a Git URL with mixed case git name but lower case composer.json name
Given an empty directory

When I try `wp package install https://github.com/CapitalWPCLI/examplecommand.git`
Then the return code should be 0
And STDERR should contain:
"""
Warning: Package name mismatch...Updating the name with correct value.
"""
And STDOUT should contain:
"""
Success: Package installed.
"""

When I run `wp package list --fields=name,pretty_name`
Then STDOUT should be a table containing rows:
| name | pretty_name |
| capitalwpcli/examplecommand | capitalwpcli/examplecommand |

When I run `wp hello-world`
Then STDOUT should contain:
"""
Success: Hello world.
"""

@github-api
Scenario: Install a package from a Git URL with mixed case git name and the same mixed case composer.json name
Given an empty directory

When I run `wp package install https://github.com/gitlost/TestMixedCaseCommand.git`
Then STDERR should be empty
And STDOUT should contain:
"""
Success: Package installed.
"""

When I run `wp package list --fields=name,pretty_name`
Then STDOUT should be a table containing rows:
| name | pretty_name |
| gitlost/testmixedcasecommand | gitlost/TestMixedCaseCommand |

When I run `wp TestMixedCaseCommand`
Then STDOUT should contain:
"""
Success: Test Mixed Case Command Name
"""

# Current releases of schlessera/test-command are PHP 5.5 dependent.
@github-api @shortened @require-php-5.5
Scenario: Install a package from Git using a shortened package identifier
Expand Down
9 changes: 7 additions & 2 deletions src/Package_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ class Package_Command extends WP_CLI_Command {
* * authors
* * version
*
* There are no optionally available fields.
* These fields are optionally available:
*
* * pretty_name
*
* ## EXAMPLES
*
Expand Down Expand Up @@ -376,6 +378,7 @@ public function install( $args, $assoc_args ) {
* These fields are optionally available:
*
* * description
* * pretty_name
*
* ## EXAMPLES
*
Expand Down Expand Up @@ -681,6 +684,7 @@ private function show_packages( $context, $packages, $assoc_args ) {
}
$package_output['update'] = $update;
$package_output['update_version'] = $update_version;
$package_output['pretty_name'] = $package->getPrettyName();
$list[ $package_output['name'] ] = $package_output;
}
}
Expand Down Expand Up @@ -742,7 +746,8 @@ private function get_installed_packages() {
}
$installed_packages = array();
foreach( $repo->getCanonicalPackages() as $package ) {
if ( in_array( $package->getName(), $installed_package_keys, true ) ) {
// Use pretty name as it's case sensitive.
if ( in_array( $package->getPrettyName(), $installed_package_keys, true ) ) {
$installed_packages[] = $package;
}
}
Expand Down