Skip to content

Commit 4a671db

Browse files
committed
YAML Test Runner: Check for variables in test body when matching
1 parent 3161d1a commit 4a671db

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/BuildPHPUnitClass.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,12 @@ protected function match(array $actions): string
347347
if (empty((array) $value)) {
348348
$output .= sprintf("\$this->assertEmpty(%s);\n", $key);
349349
} else {
350-
$output .= sprintf("\$this->assertEquals(%s, %s);\n", var_export($value, true), $key);
350+
// Check for variables in test body:
351+
$body = var_export($value, true);
352+
if (str_contains($body, '$')){
353+
$body = preg_replace('/"|\'(\$[a-z_]+)"|\'/', '${1}', $body);
354+
}
355+
$output .= sprintf("\$this->assertEquals(%s, %s);\n", $body, $key);
351356
}
352357
break;
353358
default:

0 commit comments

Comments
 (0)