Skip to content

Commit

Permalink
Merge pull request #233 from wp-cli/fix/regex
Browse files Browse the repository at this point in the history
Replace variables in regexes
  • Loading branch information
swissspidy authored Dec 18, 2024
2 parents e821347 + 51f1de0 commit 083a54e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Context/ThenStepDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 );
Expand Down

0 comments on commit 083a54e

Please sign in to comment.