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
27 changes: 27 additions & 0 deletions features/bootstrap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,30 @@ Feature: Bootstrap WP-CLI
"""
WP-Override-CLI
"""

Scenario: Template paths should be resolved correctly when PHAR is renamed

Given an empty directory
And a new Phar with the same version
And a WP installation
And I run `wp plugin install https://github.com/wp-cli-test/generic-example-plugin/releases/download/v0.1.1/generic-example-plugin.0.1.1.zip --activate`
And I run `wp plugin deactivate generic-example-plugin`

When I run `php {PHAR_PATH} plugin status generic-example-plugin`
Then STDOUT should contain:
"""
Plugin generic-example-plugin details:
Name: Example Plugin
Status: Inactive
"""
And STDERR should be empty

When I run `cp {PHAR_PATH} wp-renamed.phar`
And I try `php wp-renamed.phar plugin status generic-example-plugin`
Then STDOUT should contain:
"""
Plugin generic-example-plugin details:
Name: Example Plugin
Status: Inactive
"""
And STDERR should be empty
2 changes: 1 addition & 1 deletion features/cli.feature
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Feature: `wp cli` tasks
When I run `{PHAR_PATH} cli update --stable < session`
Then STDOUT should contain:
"""
You have version 2.8.0. Would you like to update to the latest stable release? [y/n]
You are currently using WP-CLI version 2.8.0. Would you like to update to the latest stable release? [y/n]
"""
And STDOUT should contain:
"""
Expand Down
27 changes: 27 additions & 0 deletions features/make-phar.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,30 @@ Feature: Check `utils/make-phar.php` output
Then the return code should be 1
And STDOUT should be empty
And STDERR should be empty

Scenario: Phar renaming affects template path resolution
Given an empty directory
And a new Phar with the same version
And a WP installation
And I run `wp plugin install https://github.com/wp-cli-test/generic-example-plugin/releases/download/v0.1.1/generic-example-plugin.0.1.1.zip --activate`
And I run `wp plugin deactivate generic-example-plugin`

When I run `php {PHAR_PATH} plugin status generic-example-plugin`
Then STDOUT should contain:
"""
Plugin generic-example-plugin details:
Name: Example Plugin
Status: Inactive
Version: 0.1.0
Author: YOUR NAME HERE
Description: PLUGIN DESCRIPTION HERE
"""
And STDERR should be empty

When I run `cp {PHAR_PATH} wp`
And I try `php wp plugin status generic-example-plugin`
Then STDERR should not contain:
"""
Error: Couldn't find plugin-status.mustache
"""
And the return code should be 0
8 changes: 4 additions & 4 deletions features/requests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Feature: Requests integration with both v1 and v2
"""
And STDERR should be empty

When I run `wp plugin install duplicate-post`
When I run `wp plugin install https://github.com/wp-cli-test/generic-example-plugin/releases/download/v0.1.1/generic-example-plugin.0.1.1.zip`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
Expand Down Expand Up @@ -102,7 +102,7 @@ Feature: Requests integration with both v1 and v2
"""
And STDERR should be empty

When I run `wp plugin install duplicate-post`
When I run `wp plugin install https://github.com/wp-cli-test/generic-example-plugin/releases/download/v0.1.1/generic-example-plugin.0.1.1.zip`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
Expand Down Expand Up @@ -212,7 +212,7 @@ Feature: Requests integration with both v1 and v2

# This can throw deprecated warnings on PHP 8.1+.
# Also, using a specific version to avoid minimum WordPress version requirement warning.
When I try `vendor/bin/wp plugin install duplicate-post --version=4.2 --activate`
When I try `vendor/bin/wp plugin install https://github.com/wp-cli-test/generic-example-plugin/releases/download/v0.1.1/generic-example-plugin.0.1.1.zip --version=4.2 --activate`
Then STDOUT should contain:
"""
Success: Installed 1 of 1 plugins.
Expand Down Expand Up @@ -242,5 +242,5 @@ Feature: Requests integration with both v1 and v2
"""
And STDOUT should contain:
"""
plugin=duplicate-post
plugin=generic-example-plugin
"""
2 changes: 1 addition & 1 deletion php/boot-phar.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}

// Store the path to the Phar early on for `Utils\phar-safe-path()` function.
define( 'WP_CLI_PHAR_PATH', getcwd() );
define( 'WP_CLI_PHAR_PATH', Phar::running( true ) );

if ( file_exists( 'phar://wp-cli.phar/php/wp-cli.php' ) ) {
define( 'WP_CLI_ROOT', 'phar://wp-cli.phar' );
Expand Down
Loading