diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index 0d2a0978..a64cc546 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -110,8 +110,8 @@ public function evaluate(string $filename, array $methods): void $relativePath = (string) preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $relativePath); // Remove escaped quote sequences (maintain namespace) $relativePath = str_replace(array_map(fn (string $quote): string => sprintf('\\%s', $quote), ['\'', '"']), '', $relativePath); - // Limit to A-Z, a-z, 0-9, '_', '-'. - $relativePath = (string) preg_replace('/[^A-Za-z0-9\\\\]/', '', $relativePath); + // Limit to Unicode letters and numbers. + $relativePath = (string) preg_replace('/[^\p{L}\p{N}\\\\]/u', '', $relativePath); $classFQN = 'P\\'.$relativePath; diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 7b3d6f9b..2c1d7e38 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1775,6 +1775,10 @@ - todo - todo in parallel + PASS Tests\Visual\UnicodeFilename + ✓ filter works with unicode characters in filename + ✓ filter with unicode regex matches unicode filename + WARN Tests\Visual\Version - visual snapshot of help command output @@ -1782,4 +1786,4 @@ ✓ pass with dataset with ('my-datas-set-value') ✓ within describe → pass with dataset with ('my-datas-set-value') - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 39 todos, 35 skipped, 1188 passed (2813 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 39 todos, 35 skipped, 1190 passed (2818 assertions) \ No newline at end of file diff --git "a/tests/.tests/Stra\303\237enTest.php" "b/tests/.tests/Stra\303\237enTest.php" new file mode 100644 index 00000000..682d1062 --- /dev/null +++ "b/tests/.tests/Stra\303\237enTest.php" @@ -0,0 +1,3 @@ +assertTrue(true); diff --git a/tests/Visual/UnicodeFilename.php b/tests/Visual/UnicodeFilename.php new file mode 100644 index 00000000..d12ed20f --- /dev/null +++ b/tests/Visual/UnicodeFilename.php @@ -0,0 +1,37 @@ + 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']); + + $process->run(); + + $output = $process->getOutput(); + + expect($output)->toContain('StraßenTest'); + expect($output)->toContain('tests unicode filename'); + expect($output)->toContain('1 passed'); +})->skipOnWindows(); + +test('filter with unicode regex matches unicode filename', function () { + $process = new Process([ + 'php', + 'bin/pest', + '--filter=.*Straß.*', + 'tests/.tests/', + '--colors=never', + ], dirname(__DIR__, 2), ['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true']); + + $process->run(); + + $output = $process->getOutput(); + + expect($output)->toContain('StraßenTest'); + expect($output)->toContain('1 passed'); +})->skipOnWindows();