@@ -59,9 +59,10 @@ class FeatureContext extends BehatContext implements ClosuredContextInterface {
5959 */
6060 private static function get_process_env_variables () {
6161 // Ensure we're using the expected `wp` binary
62- $ bin_dir = getenv ( 'WP_CLI_BIN_DIR ' ) ?: realpath ( __DIR__ . "/../../bin " );
62+ $ bin_dir = getenv ( 'WP_CLI_BIN_DIR ' ) ?: realpath ( __DIR__ . '/../../bin ' );
63+ $ vendor_dir = realpath ( __DIR__ . '/../../vendor/bin ' );
6364 $ env = array (
64- 'PATH ' => $ bin_dir . ': ' . getenv ( 'PATH ' ),
65+ 'PATH ' => $ bin_dir . ': ' . $ vendor_dir . ' : ' . getenv ( 'PATH ' ),
6566 'BEHAT_RUN ' => 1 ,
6667 'HOME ' => '/tmp/wp-cli-home ' ,
6768 );
@@ -218,9 +219,21 @@ public function create_run_dir() {
218219 public function build_phar ( $ version = 'same ' ) {
219220 $ this ->variables ['PHAR_PATH ' ] = $ this ->variables ['RUN_DIR ' ] . '/ ' . uniqid ( "wp-cli-build- " , TRUE ) . '.phar ' ;
220221
222+ // Test running against WP-CLI proper
223+ $ make_phar_path = __DIR__ . '/../../utils/make-phar.php ' ;
224+ if ( ! file_exists ( $ make_phar_path ) ) {
225+ // Test running against a package installed as a WP-CLI dependency
226+ // WP-CLI installed as a project dependency
227+ $ make_phar_path = __DIR__ . '/../../../../../utils/make-phar.php ' ;
228+ if ( ! file_exists ( $ make_phar_path ) ) {
229+ // WP-CLI as a dependency of this project
230+ $ make_phar_path = __DIR__ . '/../../vendor/wp-cli/wp-cli/utils/make-phar.php ' ;
231+ }
232+ }
233+
221234 $ this ->proc ( Utils \esc_cmd (
222235 'php -dphar.readonly=0 %1$s %2$s --version=%3$s && chmod +x %2$s ' ,
223- __DIR__ . ' /../../utils/make-phar.php ' ,
236+ $ make_phar_path ,
224237 $ this ->variables ['PHAR_PATH ' ],
225238 $ version
226239 ) )->run_check ();
0 commit comments