From f91f28c9d9b943571301553ef01838a789f5a29e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 13 Jan 2026 16:26:13 +0100 Subject: [PATCH 1/3] Replace inner variables first --- src/Context/FeatureContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 65d29c38..77d4a005 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -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 ); } From 417a3c3d8dcad9c907bd89333969156561e3743e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 13 Jan 2026 16:26:21 +0100 Subject: [PATCH 2/3] Add another complex test case --- features/steps.feature | 3 +++ 1 file changed, 3 insertions(+) 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}` From 15fcc32a04744139fd474316fb6bce3206fcb178 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 13 Jan 2026 16:26:33 +0100 Subject: [PATCH 3/3] Fix edge case where shell_exec doesn't return a string --- src/Context/FeatureContext.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 77d4a005..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];