From 24f85354e28ddf27f00ee23be8afc306a2ecc41b Mon Sep 17 00:00:00 2001 From: Alex Rock Ancelet Date: Sat, 30 May 2020 00:11:26 +0200 Subject: [PATCH] Normalize Windows dir name in TestCaseFactory --- src/Factories/TestCaseFactory.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index e36613ab..3f6e4f0d 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -158,10 +158,18 @@ final class TestCaseFactory */ public function makeClassFromFilename(string $filename): string { + if ('\\' === DIRECTORY_SEPARATOR) { + // In case Windows, strtolower drive name, like in UsesCall. + $filename = (string) preg_replace_callback('~^(?P[a-z]+:\\\)~i', function ($match): string { + return strtolower($match['drive']); + }, $filename); + } + $rootPath = TestSuite::getInstance()->rootPath; $relativePath = str_replace($rootPath . DIRECTORY_SEPARATOR, '', $filename); // Strip out any %-encoded octets. $relativePath = (string) preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $relativePath); + $relativePath = str_replace('\\', '/', $relativePath); // Limit to A-Z, a-z, 0-9, '_', '-'. $relativePath = (string) preg_replace('/[^A-Za-z0-9.\/]/', '', $relativePath);