feat: adds fixture

This commit is contained in:
Nuno Maduro
2025-06-27 02:15:28 +01:00
parent 163479ae60
commit ef76c04dbe
3 changed files with 37 additions and 1 deletions

View File

@ -278,3 +278,28 @@ if (! function_exists('mutates')) {
}
}
}
if (! function_exists('fixture')) {
/**
* Returns the absolute path to a fixture file.
*/
function fixture(string $file): string
{
$file = implode(DIRECTORY_SEPARATOR, [
TestSuite::getInstance()->rootPath,
TestSuite::getInstance()->testPath,
'Fixtures',
str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $file),
]);
$fileRealPath = realpath($file);
if ($fileRealPath === false) {
throw new InvalidArgumentException(
'The fixture file ['.$file.'] does not exist.',
);
}
return $fileRealPath;
}
}

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string
{
return '4.0.0-alpha.2';
return '4.0.0-alpha.3';
}
function testDirectory(string $file = ''): string