diff --git a/features/bootstrap.feature b/features/bootstrap.feature index 839acc8ee..b2ef01e7a 100644 --- a/features/bootstrap.feature +++ b/features/bootstrap.feature @@ -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 diff --git a/features/cli.feature b/features/cli.feature index 0728ad1fa..a444c2c4c 100644 --- a/features/cli.feature +++ b/features/cli.feature @@ -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: """ diff --git a/features/make-phar.feature b/features/make-phar.feature index 069e4b7f6..5ce5e516f 100644 --- a/features/make-phar.feature +++ b/features/make-phar.feature @@ -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 diff --git a/features/requests.feature b/features/requests.feature index c4ab0d0d5..6c2cf1796 100644 --- a/features/requests.feature +++ b/features/requests.feature @@ -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. @@ -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. @@ -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. @@ -242,5 +242,5 @@ Feature: Requests integration with both v1 and v2 """ And STDOUT should contain: """ - plugin=duplicate-post + plugin=generic-example-plugin """ diff --git a/php/boot-phar.php b/php/boot-phar.php index 406402e97..e5f94a262 100644 --- a/php/boot-phar.php +++ b/php/boot-phar.php @@ -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' );