From b71bfc513a595865b2fbe76de9325c9d65942531 Mon Sep 17 00:00:00 2001 From: nuno maduro Date: Fri, 10 Apr 2026 12:23:49 +0100 Subject: [PATCH] chore: guards --- src/Factories/TestCaseFactory.php | 4 ++-- src/Plugins/Parallel/Paratest/WrapperRunner.php | 16 ++++++++++++---- src/Support/StateGenerator.php | 4 ++++ tests/.tests/StraßenTest.php | 3 +++ 4 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 tests/.tests/StraßenTest.php diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index 4599ee77..6f120c27 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -116,8 +116,8 @@ final class TestCaseFactory $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/src/Plugins/Parallel/Paratest/WrapperRunner.php b/src/Plugins/Parallel/Paratest/WrapperRunner.php index 69be6032..331b0c7d 100644 --- a/src/Plugins/Parallel/Paratest/WrapperRunner.php +++ b/src/Plugins/Parallel/Paratest/WrapperRunner.php @@ -492,15 +492,23 @@ final class WrapperRunner implements RunnerInterface */ private function getTestFiles(SuiteLoader $suiteLoader): array { - /** @var array $files */ - $files = array_fill_keys(array_values(array_filter( + /** @var array $files */ + $files = []; + + foreach (array_filter( $suiteLoader->tests, fn (string $filename): bool => ! str_ends_with($filename, "eval()'d code") - )), null); + ) as $filename) { + $resolved = realpath($filename) ?: $filename; + $files[$resolved] = null; + } foreach (TestSuite::getInstance()->tests->getFilenames() as $filename) { if ($this->shouldIncludeBootstrappedTestFile($filename)) { - $files[$filename] = null; + $resolved = realpath($filename) + ?: realpath($this->options->cwd.DIRECTORY_SEPARATOR.$filename) + ?: $filename; + $files[$resolved] = null; } } diff --git a/src/Support/StateGenerator.php b/src/Support/StateGenerator.php index 3226343e..9872f52d 100644 --- a/src/Support/StateGenerator.php +++ b/src/Support/StateGenerator.php @@ -185,6 +185,10 @@ final class StateGenerator { foreach ($testResultEvents as $events) { foreach ($events as $event) { + if (! $event->test()->isTestMethod()) { + continue; + } + $state->add(TestResult::fromPestParallelTestCase( $event->test(), $type, diff --git a/tests/.tests/StraßenTest.php b/tests/.tests/StraßenTest.php new file mode 100644 index 00000000..682d1062 --- /dev/null +++ b/tests/.tests/StraßenTest.php @@ -0,0 +1,3 @@ +assertTrue(true);