diff --git a/features/steps.feature b/features/steps.feature index 7ee03d39..a1575f40 100644 --- a/features/steps.feature +++ b/features/steps.feature @@ -74,6 +74,9 @@ Feature: Make sure "Given", "When", "Then" steps work as expected Then STDOUT should match /^WP_CLI_PHP_ARGS=-dopen_basedir=.* ?wp cli info/ And STDERR should be empty + When I run `echo {INVOKE_WP_CLI_WITH_PHP_ARGS--dopen_basedir={RUN_DIR}} eval 'echo "{RUN_DIR}";'` + Then STDOUT should match /^WP_CLI_PHP_ARGS=-dopen_basedir=(.*)(.*) ?wp eval echo "\1";/ + @require-mysql-or-mariadb Scenario: SQL related variables When I run `echo {MYSQL_BINARY}` diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 65d29c38..3c9dbb0e 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -762,7 +762,7 @@ private static function terminate_proc( $master_pid ): void { $output = shell_exec( "ps -o ppid,pid,command | grep $master_pid" ); - foreach ( explode( PHP_EOL, $output ) as $line ) { + foreach ( explode( PHP_EOL, $output ? $output : '' ) as $line ) { if ( preg_match( '/^\s*(\d+)\s+(\d+)/', $line, $matches ) ) { $parent = $matches[1]; $child = $matches[2]; @@ -939,10 +939,10 @@ protected static function bootstrap_feature_context(): void { * @return string */ public function replace_variables( $str ) { + $str = preg_replace_callback( '/\{([A-Z_][A-Z_0-9]*)\}/', [ $this, 'replace_var' ], $str ); if ( false !== strpos( $str, '{INVOKE_WP_CLI_WITH_PHP_ARGS-' ) ) { $str = $this->replace_invoke_wp_cli_with_php_args( $str ); } - $str = preg_replace_callback( '/\{([A-Z_][A-Z_0-9]*)\}/', [ $this, 'replace_var' ], $str ); if ( false !== strpos( $str, '{WP_VERSION-' ) ) { $str = $this->replace_wp_versions( $str ); }