@@ -59,9 +59,10 @@ class FeatureContext extends BehatContext implements ClosuredContextInterface {
59
59
*/
60
60
private static function get_process_env_variables () {
61
61
// 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 ' );
63
64
$ env = array (
64
- 'PATH ' => $ bin_dir . ': ' . getenv ( 'PATH ' ),
65
+ 'PATH ' => $ bin_dir . ': ' . $ vendor_dir . ' : ' . getenv ( 'PATH ' ),
65
66
'BEHAT_RUN ' => 1 ,
66
67
'HOME ' => '/tmp/wp-cli-home ' ,
67
68
);
@@ -218,9 +219,21 @@ public function create_run_dir() {
218
219
public function build_phar ( $ version = 'same ' ) {
219
220
$ this ->variables ['PHAR_PATH ' ] = $ this ->variables ['RUN_DIR ' ] . '/ ' . uniqid ( "wp-cli-build- " , TRUE ) . '.phar ' ;
220
221
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
+
221
234
$ this ->proc ( Utils \esc_cmd (
222
235
'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 ,
224
237
$ this ->variables ['PHAR_PATH ' ],
225
238
$ version
226
239
) )->run_check ();
0 commit comments