diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index b23082fd6..f2bb3e1bd 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -94,7 +94,8 @@ public function evaluate(string $filename, array $methods): void $filename = (string) preg_replace_callback('~^(?P[a-z]+:\\\)~i', static fn (array $match): string => strtolower($match['drive']), $filename); } - $filename = str_replace('\\\\', '\\', addslashes((string) realpath($filename))); + $realpath = (string) realpath($filename); + $filename = str_replace('\\\\', '\\', addslashes($realpath)); $rootPath = TestSuite::getInstance()->rootPath; $relativePath = str_replace($rootPath.DIRECTORY_SEPARATOR, '', $filename); @@ -149,6 +150,8 @@ public function evaluate(string $filename, array $methods): void $attributesCode = Attributes::code($this->attributes); + $filenameLiteral = var_export($realpath, true); + $methodsCode = implode('', array_map( fn (TestCaseMethodFactory $methodFactory): string => $methodFactory->buildForEvaluation(), $methods @@ -166,7 +169,7 @@ public function evaluate(string $filename, array $methods): void final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN { $traitsCode - public static \$__filename = '$filename'; + public static \$__filename = $filenameLiteral; $methodsCode }