chore: guards

This commit is contained in:
nuno maduro
2026-04-10 12:23:49 +01:00
parent 75938ac9eb
commit b71bfc513a
4 changed files with 21 additions and 6 deletions

View File

@ -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;

View File

@ -492,15 +492,23 @@ final class WrapperRunner implements RunnerInterface
*/
private function getTestFiles(SuiteLoader $suiteLoader): array
{
/** @var array<string, non-empty-string> $files */
$files = array_fill_keys(array_values(array_filter(
/** @var array<string, null> $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;
}
}

View File

@ -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,

View File

@ -0,0 +1,3 @@
<?php
it('tests unicode filename with ß')->assertTrue(true);