@@ -198,6 +198,12 @@ public static function get_bin_path() {
198198 * Get the environment variables required for launched `wp` processes
199199 */
200200 private static function get_process_env_variables () {
201+ static $ env = null ;
202+
203+ if ( null !== $ env ) {
204+ return $ env ;
205+ }
206+
201207 // Ensure we're using the expected `wp` binary.
202208 $ bin_path = self ::get_bin_path ();
203209 wp_cli_behat_env_debug ( "WP-CLI binary path: {$ bin_path }" );
@@ -333,26 +339,15 @@ public static function prepare( BeforeSuiteScope $scope ) {
333339 }
334340
335341 $ result = Process::create ( 'wp cli info ' , null , self ::get_process_env_variables () )->run_check ();
336- echo PHP_EOL ;
337- echo $ result ->stdout ;
338- echo PHP_EOL ;
342+ echo "{$ result ->stdout }\n" ;
339343
340344 self ::cache_wp_files ();
341345
342346 $ result = Process::create ( Utils \esc_cmd ( 'wp core version --debug --path=%s ' , self ::$ cache_dir ), null , self ::get_process_env_variables () )->run_check ();
347+ echo "[Debug messages] \n" ;
348+ echo "{$ result ->stderr }\n" ;
343349
344- $ ci = getenv ( 'CI ' );
345- $ travis = getenv ( 'TRAVIS ' );
346- if ( $ travis || $ ci ) {
347- $ travis && print ( "travis_fold:start:wp_cli_debug \n" );
348- echo "[Debug messages] \n" ;
349- echo $ result ->stderr ;
350- $ travis && print ( "travis_fold:end:wp_cli_debug \n" );
351- }
352-
353- echo PHP_EOL ;
354- echo 'WordPress ' . $ result ->stdout ;
355- echo PHP_EOL ;
350+ echo "WordPress {$ result ->stdout }\n" ;
356351
357352 // Remove install cache if any (not setting the static var).
358353 $ wp_version = getenv ( 'WP_VERSION ' );
@@ -361,6 +356,10 @@ public static function prepare( BeforeSuiteScope $scope ) {
361356 if ( file_exists ( $ install_cache_dir ) ) {
362357 self ::remove_dir ( $ install_cache_dir );
363358 }
359+
360+ if ( getenv ( 'WP_CLI_TEST_DEBUG_BEHAT_ENV ' ) ) {
361+ exit ;
362+ }
364363 }
365364
366365 /**
0 commit comments