mirror of
https://github.com/pestphp/pest.git
synced 2026-07-21 17:10:03 +02:00
fix: package lock fingerprint
This commit is contained in:
@@ -11,41 +11,41 @@
|
||||
// beforeEach()->with() inside describe blocks
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('beforeEach()->with() applies dataset to tests', function () {
|
||||
describe('beforeEach()->with() applies dataset to tests', function (): void {
|
||||
beforeEach()->with([10]);
|
||||
|
||||
test('receives the dataset value', function ($value) {
|
||||
test('receives the dataset value', function ($value): void {
|
||||
expect($value)->toBe(10);
|
||||
});
|
||||
|
||||
it('also receives the dataset value in it()', function ($value) {
|
||||
it('also receives the dataset value in it()', function ($value): void {
|
||||
expect($value)->toBe(10);
|
||||
});
|
||||
});
|
||||
|
||||
describe('beforeEach()->with() with multiple dataset values', function () {
|
||||
describe('beforeEach()->with() with multiple dataset values', function (): void {
|
||||
beforeEach()->with([1, 2, 3]);
|
||||
|
||||
test('receives each value from the dataset', function ($value) {
|
||||
test('receives each value from the dataset', function ($value): void {
|
||||
expect($value)->toBeIn([1, 2, 3]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('beforeEach()->with() with keyed dataset', function () {
|
||||
describe('beforeEach()->with() with keyed dataset', function (): void {
|
||||
beforeEach()->with(['first' => [10], 'second' => [20]]);
|
||||
|
||||
test('receives keyed dataset values', function ($value) {
|
||||
test('receives keyed dataset values', function ($value): void {
|
||||
expect($value)->toBeIn([10, 20]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('beforeEach()->with() with closure dataset', function () {
|
||||
describe('beforeEach()->with() with closure dataset', function (): void {
|
||||
beforeEach()->with(function () {
|
||||
yield [100];
|
||||
yield [200];
|
||||
});
|
||||
|
||||
test('receives values from closure dataset', function ($value) {
|
||||
test('receives values from closure dataset', function ($value): void {
|
||||
expect($value)->toBeIn([100, 200]);
|
||||
});
|
||||
});
|
||||
@@ -54,30 +54,30 @@ describe('beforeEach()->with() with closure dataset', function () {
|
||||
// describe()->with() method chaining
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('describe()->with() passes dataset to tests', function () {
|
||||
test('receives the dataset value', function ($value) {
|
||||
describe('describe()->with() passes dataset to tests', function (): void {
|
||||
test('receives the dataset value', function ($value): void {
|
||||
expect($value)->toBe(42);
|
||||
});
|
||||
|
||||
it('also receives it in it()', function ($value) {
|
||||
it('also receives it in it()', function ($value): void {
|
||||
expect($value)->toBe(42);
|
||||
});
|
||||
})->with([42]);
|
||||
|
||||
describe('describe()->with() with multiple values', function () {
|
||||
test('receives each value', function ($value) {
|
||||
describe('describe()->with() with multiple values', function (): void {
|
||||
test('receives each value', function ($value): void {
|
||||
expect($value)->toBeIn([5, 10, 15]);
|
||||
});
|
||||
})->with([5, 10, 15]);
|
||||
|
||||
describe('describe()->with() with keyed dataset', function () {
|
||||
test('receives keyed values', function ($value) {
|
||||
describe('describe()->with() with keyed dataset', function (): void {
|
||||
test('receives keyed values', function ($value): void {
|
||||
expect($value)->toBeIn([100, 200]);
|
||||
});
|
||||
})->with(['alpha' => [100], 'beta' => [200]]);
|
||||
|
||||
describe('describe()->with() with closure dataset', function () {
|
||||
test('receives closure dataset values', function ($value) {
|
||||
describe('describe()->with() with closure dataset', function (): void {
|
||||
test('receives closure dataset values', function ($value): void {
|
||||
expect($value)->toBeIn([7, 14]);
|
||||
});
|
||||
})->with(function () {
|
||||
@@ -89,33 +89,33 @@ describe('describe()->with() with closure dataset', function () {
|
||||
// Nested describe blocks with datasets
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('outer with dataset', function () {
|
||||
describe('inner without dataset', function () {
|
||||
test('inherits outer dataset', function (...$args) {
|
||||
describe('outer with dataset', function (): void {
|
||||
describe('inner without dataset', function (): void {
|
||||
test('inherits outer dataset', function (...$args): void {
|
||||
expect($args)->toBe([1]);
|
||||
});
|
||||
});
|
||||
})->with([1]);
|
||||
|
||||
describe('nested describe blocks with datasets at multiple levels', function () {
|
||||
describe('level 1', function () {
|
||||
test('receives level 1 dataset', function (...$args) {
|
||||
describe('nested describe blocks with datasets at multiple levels', function (): void {
|
||||
describe('level 1', function (): void {
|
||||
test('receives level 1 dataset', function (...$args): void {
|
||||
expect($args)->toBe([10]);
|
||||
});
|
||||
|
||||
describe('level 2', function () {
|
||||
test('receives datasets from all ancestor levels', function (...$args) {
|
||||
describe('level 2', function (): void {
|
||||
test('receives datasets from all ancestor levels', function (...$args): void {
|
||||
expect($args)->toBe([10, 20]);
|
||||
});
|
||||
})->with([20]);
|
||||
})->with([10]);
|
||||
});
|
||||
|
||||
describe('deeply nested describe with datasets', function () {
|
||||
describe('a', function () {
|
||||
describe('b', function () {
|
||||
describe('c', function () {
|
||||
test('receives all ancestor datasets', function (...$args) {
|
||||
describe('deeply nested describe with datasets', function (): void {
|
||||
describe('a', function (): void {
|
||||
describe('b', function (): void {
|
||||
describe('c', function (): void {
|
||||
test('receives all ancestor datasets', function (...$args): void {
|
||||
expect($args)->toBe([1, 2, 3]);
|
||||
});
|
||||
})->with([3]);
|
||||
@@ -127,19 +127,19 @@ describe('deeply nested describe with datasets', function () {
|
||||
// Combining hook datasets with test-level datasets
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('beforeEach()->with() combined with test->with()', function () {
|
||||
describe('beforeEach()->with() combined with test->with()', function (): void {
|
||||
beforeEach()->with([10]);
|
||||
|
||||
test('receives both datasets as cross product', function ($hookValue, $testValue) {
|
||||
expect($hookValue)->toBe(10);
|
||||
expect($testValue)->toBeIn([1, 2]);
|
||||
test('receives both datasets as cross product', function ($hookValue, $testValue): void {
|
||||
expect($hookValue)->toBe(10)
|
||||
->and($testValue)->toBeIn([1, 2]);
|
||||
})->with([1, 2]);
|
||||
});
|
||||
|
||||
describe('describe()->with() combined with test->with()', function () {
|
||||
test('receives both datasets', function ($describeValue, $testValue) {
|
||||
expect($describeValue)->toBe(5);
|
||||
expect($testValue)->toBeIn([50, 60]);
|
||||
describe('describe()->with() combined with test->with()', function (): void {
|
||||
test('receives both datasets', function ($describeValue, $testValue): void {
|
||||
expect($describeValue)->toBe(5)
|
||||
->and($testValue)->toBeIn([50, 60]);
|
||||
})->with([50, 60]);
|
||||
})->with([5]);
|
||||
|
||||
@@ -147,33 +147,33 @@ describe('describe()->with() combined with test->with()', function () {
|
||||
// beforeEach()->with() combined with beforeEach closure
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('beforeEach closure and beforeEach()->with() coexist', function () {
|
||||
beforeEach(function () {
|
||||
describe('beforeEach closure and beforeEach()->with() coexist', function (): void {
|
||||
beforeEach(function (): void {
|
||||
$this->setupValue = 'initialized';
|
||||
});
|
||||
|
||||
beforeEach()->with([99]);
|
||||
|
||||
test('has both the closure state and dataset', function ($value) {
|
||||
expect($this->setupValue)->toBe('initialized');
|
||||
expect($value)->toBe(99);
|
||||
test('has both the closure state and dataset', function ($value): void {
|
||||
expect($this->setupValue)->toBe('initialized')
|
||||
->and($value)->toBe(99);
|
||||
});
|
||||
});
|
||||
|
||||
describe('beforeEach()->with() does not interfere with closure hooks', function () {
|
||||
beforeEach(function () {
|
||||
describe('beforeEach()->with() does not interfere with closure hooks', function (): void {
|
||||
beforeEach(function (): void {
|
||||
$this->counter = 1;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function (): void {
|
||||
$this->counter++;
|
||||
});
|
||||
|
||||
beforeEach()->with([42]);
|
||||
|
||||
test('closures run in order and dataset is applied', function ($value) {
|
||||
expect($this->counter)->toBe(2);
|
||||
expect($value)->toBe(42);
|
||||
test('closures run in order and dataset is applied', function ($value): void {
|
||||
expect($this->counter)->toBe(2)
|
||||
->and($value)->toBe(42);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -181,24 +181,24 @@ describe('beforeEach()->with() does not interfere with closure hooks', function
|
||||
// Dataset isolation between describe blocks
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('first describe with dataset', function () {
|
||||
describe('first describe with dataset', function (): void {
|
||||
beforeEach()->with([111]);
|
||||
|
||||
test('gets its own dataset', function ($value) {
|
||||
test('gets its own dataset', function ($value): void {
|
||||
expect($value)->toBe(111);
|
||||
});
|
||||
});
|
||||
|
||||
describe('second describe with different dataset', function () {
|
||||
describe('second describe with different dataset', function (): void {
|
||||
beforeEach()->with([222]);
|
||||
|
||||
test('gets its own dataset, not the sibling', function ($value) {
|
||||
test('gets its own dataset, not the sibling', function ($value): void {
|
||||
expect($value)->toBe(222);
|
||||
});
|
||||
});
|
||||
|
||||
describe('third describe without dataset', function () {
|
||||
test('has no dataset leaking from siblings', function () {
|
||||
describe('third describe without dataset', function (): void {
|
||||
test('has no dataset leaking from siblings', function (): void {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
});
|
||||
@@ -207,23 +207,23 @@ describe('third describe without dataset', function () {
|
||||
// describe()->with() combined with beforeEach hooks
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('describe()->with() with beforeEach closure', function () {
|
||||
beforeEach(function () {
|
||||
describe('describe()->with() with beforeEach closure', function (): void {
|
||||
beforeEach(function (): void {
|
||||
$this->hookRan = true;
|
||||
});
|
||||
|
||||
test('both hook and dataset work', function ($value) {
|
||||
expect($this->hookRan)->toBeTrue();
|
||||
expect($value)->toBe(77);
|
||||
test('both hook and dataset work', function ($value): void {
|
||||
expect($this->hookRan)->toBeTrue()
|
||||
->and($value)->toBe(77);
|
||||
});
|
||||
})->with([77]);
|
||||
|
||||
describe('describe()->with() with afterEach closure', function () {
|
||||
afterEach(function () {
|
||||
describe('describe()->with() with afterEach closure', function (): void {
|
||||
afterEach(function (): void {
|
||||
expect($this->value)->toBe(88);
|
||||
});
|
||||
|
||||
test('dataset is available and afterEach runs', function ($value) {
|
||||
test('dataset is available and afterEach runs', function ($value): void {
|
||||
$this->value = $value;
|
||||
expect($value)->toBe(88);
|
||||
});
|
||||
@@ -233,18 +233,18 @@ describe('describe()->with() with afterEach closure', function () {
|
||||
// Multiple tests in a describe with beforeEach()->with()
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('multiple tests share the same beforeEach dataset', function () {
|
||||
describe('multiple tests share the same beforeEach dataset', function (): void {
|
||||
beforeEach()->with([33]);
|
||||
|
||||
test('first test gets the dataset', function ($value) {
|
||||
test('first test gets the dataset', function ($value): void {
|
||||
expect($value)->toBe(33);
|
||||
});
|
||||
|
||||
test('second test also gets the dataset', function ($value) {
|
||||
test('second test also gets the dataset', function ($value): void {
|
||||
expect($value)->toBe(33);
|
||||
});
|
||||
|
||||
it('third test with it() also gets the dataset', function ($value) {
|
||||
it('third test with it() also gets the dataset', function ($value): void {
|
||||
expect($value)->toBe(33);
|
||||
});
|
||||
});
|
||||
@@ -253,21 +253,21 @@ describe('multiple tests share the same beforeEach dataset', function () {
|
||||
// Nested describe with beforeEach()->with() at inner level
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('outer describe', function () {
|
||||
beforeEach(function () {
|
||||
describe('outer describe', function (): void {
|
||||
beforeEach(function (): void {
|
||||
$this->outer = true;
|
||||
});
|
||||
|
||||
describe('inner describe with dataset on hook', function () {
|
||||
describe('inner describe with dataset on hook', function (): void {
|
||||
beforeEach()->with([55]);
|
||||
|
||||
test('inherits outer beforeEach and has inner dataset', function ($value) {
|
||||
expect($this->outer)->toBeTrue();
|
||||
expect($value)->toBe(55);
|
||||
test('inherits outer beforeEach and has inner dataset', function ($value): void {
|
||||
expect($this->outer)->toBeTrue()
|
||||
->and($value)->toBe(55);
|
||||
});
|
||||
});
|
||||
|
||||
test('outer test is unaffected by inner dataset', function () {
|
||||
test('outer test is unaffected by inner dataset', function (): void {
|
||||
expect($this->outer)->toBeTrue();
|
||||
});
|
||||
});
|
||||
@@ -276,12 +276,12 @@ describe('outer describe', function () {
|
||||
// describe()->with() with depends
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
describe('describe()->with() preserves depends', function () {
|
||||
test('first', function ($value) {
|
||||
describe('describe()->with() preserves depends', function (): void {
|
||||
test('first', function ($value): void {
|
||||
expect($value)->toBe(9);
|
||||
});
|
||||
|
||||
test('second', function ($value) {
|
||||
test('second', function ($value): void {
|
||||
expect($value)->toBe(9);
|
||||
})->depends('first');
|
||||
})->with([9]);
|
||||
|
||||
Reference in New Issue
Block a user