refacto: structure

This commit is contained in:
Nuno Maduro
2021-12-05 14:40:08 +00:00
parent e64b6fe924
commit b1f9ce2283
17 changed files with 79 additions and 61 deletions

View File

@ -1,9 +1,9 @@
<?php
use Pest\Datasets;
use Pest\Exceptions\DatasetAlreadyExist;
use Pest\Exceptions\DatasetDoesNotExist;
use Pest\Plugin;
use Pest\Repositories\DatasetsRepository;
beforeEach(function () {
$this->foo = 'bar';
@ -13,28 +13,28 @@ it('throws exception if dataset does not exist', function () {
$this->expectException(DatasetDoesNotExist::class);
$this->expectExceptionMessage("A dataset with the name `first` does not exist. You can create it using `dataset('first', ['a', 'b']);`.");
Datasets::resolve('foo', ['first']);
DatasetsRepository::resolve('foo', ['first']);
});
it('throws exception if dataset already exist', function () {
Datasets::set('second', [[]]);
DatasetsRepository::set('second', [[]]);
$this->expectException(DatasetAlreadyExist::class);
$this->expectExceptionMessage('A dataset with the name `second` already exist.');
Datasets::set('second', [[]]);
DatasetsRepository::set('second', [[]]);
});
it('sets closures', function () {
Datasets::set('foo', function () {
DatasetsRepository::set('foo', function () {
yield [1];
});
expect(Datasets::resolve('foo', ['foo']))->toBe(['foo with (1)' => [1]]);
expect(DatasetsRepository::resolve('foo', ['foo']))->toBe(['foo with (1)' => [1]]);
});
it('sets arrays', function () {
Datasets::set('bar', [[2]]);
DatasetsRepository::set('bar', [[2]]);
expect(Datasets::resolve('bar', ['bar']))->toBe(['bar with (2)' => [2]]);
expect(DatasetsRepository::resolve('bar', ['bar']))->toBe(['bar with (2)' => [2]]);
});
it('gets bound to test case object', function () {