Add DatasetInfo support class

This commit is contained in:
Fabio Ivona
2022-09-22 10:33:15 +02:00
parent cbee6e76b0
commit 80854d5f87
6 changed files with 101 additions and 44 deletions

View File

@ -9,8 +9,8 @@ use Pest\PendingCalls\TestCall;
use Pest\PendingCalls\UsesCall;
use Pest\Repositories\DatasetsRepository;
use Pest\Support\Backtrace;
use Pest\Support\DatasetInfo;
use Pest\Support\HigherOrderTapProxy;
use Pest\Support\Str;
use Pest\TestSuite;
use PHPUnit\Framework\TestCase;
@ -61,16 +61,7 @@ if (! function_exists('dataset')) {
*/
function dataset(string $name, Closure|iterable $dataset): void
{
$file = Backtrace::datasetsFile();
$filename = Str::afterLast($file, DIRECTORY_SEPARATOR);
$scope = Str::beforeLast($file, DIRECTORY_SEPARATOR);
if (Str::afterLast($scope, DIRECTORY_SEPARATOR) === 'Datasets') {
$scope = Str::beforeLast($scope, DIRECTORY_SEPARATOR);
} elseif ($filename !== 'Datasets.php') {
$scope = $file;
}
$scope = DatasetInfo::scope(Backtrace::datasetsFile());
DatasetsRepository::set($name, $dataset, $scope);
}
}