From 51f1de04783af0d972803dd2ead777a195aa3858 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 18 Dec 2024 10:12:44 +0100 Subject: [PATCH] Replace variables in regexes --- src/Context/ThenStepDefinitions.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Context/ThenStepDefinitions.php b/src/Context/ThenStepDefinitions.php index 792cf571..7ec476b1 100644 --- a/src/Context/ThenStepDefinitions.php +++ b/src/Context/ThenStepDefinitions.php @@ -243,7 +243,9 @@ public function then_a_specific_file_folder_should_exist( $path, $type, $strictl * @Then /^the contents of the (.+) file should( not)? match (((\/.+\/)|(#.+#))([a-z]+)?)$/ */ public function then_the_contents_of_a_specific_file_should_match( $path, $not, $expected ) { - $path = $this->replace_variables( $path ); + $path = $this->replace_variables( $path ); + $expected = $this->replace_variables( $expected ); + // If it's a relative path, make it relative to the current test dir. if ( '/' !== $path[0] ) { $path = $this->variables['RUN_DIR'] . "/$path"; @@ -260,6 +262,8 @@ public function then_the_contents_of_a_specific_file_should_match( $path, $not, * @Then /^(STDOUT|STDERR) should( not)? match (((\/.+\/)|(#.+#))([a-z]+)?)$/ */ public function then_stdout_stderr_should_match_a_string( $stream, $not, $expected ) { + $expected = $this->replace_variables( $expected ); + $stream = strtolower( $stream ); if ( $not ) { $this->assert_not_regex( $expected, $this->result->$stream );