diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 47a94dac..07bb3299 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -450,11 +450,12 @@ private static function get_process_env_variables(): array { $path_separator = Utils\is_windows() ? ';' : ':'; $php_binary_path = dirname( PHP_BINARY ); $env = [ - 'PATH' => $php_binary_path . $path_separator . $bin_path . $path_separator . getenv( 'PATH' ), - 'BEHAT_RUN' => 1, - 'HOME' => sys_get_temp_dir() . '/wp-cli-home', - 'COMPOSER_HOME' => sys_get_temp_dir() . '/wp-cli-composer-home', - 'TEST_RUN_DIR' => self::$behat_run_dir, + 'PATH' => $php_binary_path . $path_separator . $bin_path . $path_separator . getenv( 'PATH' ), + 'BEHAT_RUN' => 1, + 'HOME' => sys_get_temp_dir() . '/wp-cli-home', + 'COMPOSER_HOME' => sys_get_temp_dir() . '/wp-cli-composer-home', + 'TEST_RUN_DIR' => self::$behat_run_dir, + 'WP_CLI_SKIP_PROMPT' => 'no', ]; $env = array_merge( $_ENV, $env ); @@ -745,8 +746,10 @@ public function beforeScenario( BeforeScenarioScope $scope ): void { public function afterScenario( AfterScenarioScope $scope ): void { if ( self::$run_dir ) { - // Remove altered WP install, unless there's an error. - if ( $scope->getTestResult()->getResultCode() <= 10 ) { + // Remove altered WP install, unless there's an error (and we are not on CI). + $is_ci = getenv( 'CI' ); + $is_debug = getenv( 'WP_CLI_TEST_DEBUG_BEHAT_ENV' ); + if ( $scope->getTestResult()->getResultCode() <= 10 || ( $is_ci && ! $is_debug ) ) { self::remove_dir( self::$run_dir ); } self::$run_dir = null;