Skip to content

Commit

Permalink
Merge pull request #50 from wp-cli/legacy_wrong_name
Browse files Browse the repository at this point in the history
Use getPrettyName; cater for legacy incorrect package names.
  • Loading branch information
schlessera authored Nov 11, 2017
2 parents b069ec3 + 346e496 commit 8ac1e64
Show file tree
Hide file tree
Showing 7 changed files with 3,441 additions and 52 deletions.
194 changes: 184 additions & 10 deletions features/package-install.feature
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Feature: Install WP-CLI packages
Then the return code should be 0
And STDERR should contain:
"""
Warning: Package name mismatch...Updating the name with correct value.
Warning: Package name mismatch...Updating from git name 'wp-cli-test/repository-name' to composer.json name 'wp-cli-test/package-name'.
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -195,24 +195,39 @@ Feature: Install WP-CLI packages
"""

@github-api
Scenario: Install a package from a Git URL with mixed case git name but lower case composer.json name
Scenario: Install a package from a Git URL with mixed-case git name but lowercase 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.
Warning: Package name mismatch...Updating from git name 'CapitalWPCLI/examplecommand' to composer.json name 'capitalwpcli/examplecommand'.
"""
And STDOUT should contain:
"""
Installing package capitalwpcli/examplecommand (dev-master)
Updating {PACKAGE_PATH}composer.json to require the package...
Registering https://github.com/CapitalWPCLI/examplecommand.git as a VCS repository...
Using Composer to install the package...
"""
And STDOUT should contain:
"""
Success: Package installed.
"""
And the {PACKAGE_PATH}composer.json file should contain:
"""
"capitalwpcli/examplecommand"
"""
And the {PACKAGE_PATH}composer.json file should not contain:
"""
"CapitalWPCLI/examplecommand"
"""

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

When I run `wp hello-world`
Then STDOUT should contain:
Expand All @@ -221,7 +236,7 @@ Feature: Install WP-CLI packages
"""

@github-api
Scenario: Install a package from a Git URL with mixed case git name and the same mixed case composer.json name
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`
Expand All @@ -230,11 +245,19 @@ Feature: Install WP-CLI packages
"""
Success: Package installed.
"""
And the {PACKAGE_PATH}composer.json file should contain:
"""
"gitlost/TestMixedCaseCommand"
"""
And the {PACKAGE_PATH}composer.json file should not contain:
"""
mixed
"""

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

When I run `wp TestMixedCaseCommand`
Then STDOUT should contain:
Expand Down Expand Up @@ -467,6 +490,103 @@ Feature: Install WP-CLI packages
schlessera/test-command
"""

Scenario: Install a package from the wp-cli package index with a mixed-case name
Given an empty directory

# Install and uninstall with case-sensitive name
When I run `wp package install GeekPress/wp-rocket-cli`
Then STDERR should be empty
And STDOUT should contain:
"""
Installing package GeekPress/wp-rocket-cli (dev-master)
Updating {PACKAGE_PATH}composer.json to require the package...
Using Composer to install the package...
"""
And STDOUT should contain:
"""
Success: Package installed.
"""
And the {PACKAGE_PATH}composer.json file should contain:
"""
GeekPress/wp-rocket-cli
"""
And the {PACKAGE_PATH}composer.json file should not contain:
"""
geek
"""

When I run `wp package list --fields=name`
Then STDOUT should be a table containing rows:
| name |
| GeekPress/wp-rocket-cli |

When I run `wp help rocket`
Then STDOUT should contain:
"""
wp rocket
"""

When I run `wp package uninstall GeekPress/wp-rocket-cli`
Then STDOUT should contain:
"""
Removing require statement from {PACKAGE_PATH}composer.json
"""
And STDOUT should contain:
"""
Success: Uninstalled package.
"""
And the {PACKAGE_PATH}composer.json file should not contain:
"""
rocket
"""

# Install with lowercase name (for BC - no warning) and uninstall with lowercase name (for BC and convenience)
When I run `wp package install geekpress/wp-rocket-cli`
Then STDERR should be empty
And STDOUT should contain:
"""
Installing package GeekPress/wp-rocket-cli (dev-master)
Updating {PACKAGE_PATH}composer.json to require the package...
Using Composer to install the package...
"""
And STDOUT should contain:
"""
Success: Package installed.
"""
And the {PACKAGE_PATH}composer.json file should contain:
"""
GeekPress/wp-rocket-cli
"""
And the {PACKAGE_PATH}composer.json file should not contain:
"""
geek
"""

When I run `wp package list --fields=name`
Then STDOUT should be a table containing rows:
| name |
| GeekPress/wp-rocket-cli |

When I run `wp help rocket`
Then STDOUT should contain:
"""
wp rocket
"""

When I run `wp package uninstall geekpress/wp-rocket-cli`
Then STDOUT should contain:
"""
Removing require statement from {PACKAGE_PATH}composer.json
"""
And STDOUT should contain:
"""
Success: Uninstalled package.
"""
And the {PACKAGE_PATH}composer.json file should not contain:
"""
rocket
"""

Scenario: Install a package in a local zip
Given an empty directory
And I run `wget -O google-sitemap-generator-cli.zip https://github.com/wp-cli/google-sitemap-generator-cli/archive/master.zip`
Expand Down Expand Up @@ -511,6 +631,60 @@ Feature: Install WP-CLI packages
wp-cli/google-sitemap-generator-cli
"""

Scenario: Install a package from Git using a shortened mixed-case package identifier but lowercase composer.json name
Given an empty directory

When I try `wp package install CapitalWPCLI/examplecommand`
Then the return code should be 0
And STDERR should contain:
"""
Warning: Package name mismatch...Updating from git name 'CapitalWPCLI/examplecommand' to composer.json name 'capitalwpcli/examplecommand'.
"""
And STDOUT should contain:
"""
Installing package capitalwpcli/examplecommand (dev-master)
Updating {PACKAGE_PATH}composer.json to require the package...
Registering https://github.com/CapitalWPCLI/examplecommand.git as a VCS repository...
Using Composer to install the package...
"""
And STDOUT should contain:
"""
Success: Package installed.
"""
And the {PACKAGE_PATH}composer.json file should contain:
"""
"capitalwpcli/examplecommand"
"""
And the {PACKAGE_PATH}composer.json file should not contain:
"""
"CapitalWPCLI/examplecommand"
"""

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

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

When I run `wp package uninstall capitalwpcli/examplecommand`
Then STDOUT should contain:
"""
Removing require statement from {PACKAGE_PATH}composer.json
"""
And STDOUT should contain:
"""
Success: Uninstalled package.
"""
And the {PACKAGE_PATH}composer.json file should not contain:
"""
capital
"""

Scenario: Install a package from a remote ZIP
Given an empty directory

Expand Down
11 changes: 11 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<phpunit
bootstrap="tests/bootstrap.php"
colors="true"
>
<testsuites>
<testsuite>
<directory prefix="spec-" suffix=".php">tests/</directory>
<directory prefix="test-" suffix=".php">tests/</directory>
</testsuite>
</testsuites>
</phpunit>
Loading

0 comments on commit 8ac1e64

Please sign in to comment.