mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
Fix file paths not being used properly
basename() will strip full path information on some systems. What is needed is to use both dirname() & basename() on paths, as recognized by all systems, and only afterwards do any replacements.
This commit is contained in:
@ -168,15 +168,15 @@ final class TestCaseFactory
|
||||
$filename = realpath($filename);
|
||||
$rootPath = TestSuite::getInstance()->rootPath;
|
||||
$relativePath = str_replace($rootPath . DIRECTORY_SEPARATOR, '', $filename);
|
||||
$relativePath = dirname(ucfirst($relativePath)) . DIRECTORY_SEPARATOR . basename($relativePath, '.php');
|
||||
$relativePath = str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath);
|
||||
|
||||
// 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);
|
||||
|
||||
$classFQN = 'P\\' . basename(ucfirst(str_replace(DIRECTORY_SEPARATOR, '\\', $relativePath)), '.php');
|
||||
$relativePath = (string) preg_replace('/[^A-Za-z0-9.\\\]/', '', $relativePath);
|
||||
|
||||
$classFQN = 'P\\' . $relativePath;
|
||||
if (class_exists($classFQN)) {
|
||||
return $classFQN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user