mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
test: adding tests for beforeEach and afterEach + empty tests for *All
This commit is contained in:
11
tests/Hooks/AfterAllTest.php
Normal file
11
tests/Hooks/AfterAllTest.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
uses()->afterAll(function () {
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
});
|
||||
|
||||
test('global afterAll execution order', function () {
|
||||
});
|
||||
|
||||
24
tests/Hooks/AfterEachTest.php
Normal file
24
tests/Hooks/AfterEachTest.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
uses()->afterEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('ith')
|
||||
->and($this->ith)
|
||||
->toBe(0);
|
||||
|
||||
$this->ith = 1;
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('ith')
|
||||
->and($this->ith)
|
||||
->toBe(1);
|
||||
});
|
||||
|
||||
test('global afterEach execution order', function () {
|
||||
expect($this)
|
||||
->not()
|
||||
->toHaveProperty('ith');
|
||||
});
|
||||
|
||||
11
tests/Hooks/BeforeAllTest.php
Normal file
11
tests/Hooks/BeforeAllTest.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
uses()->beforeAll(function () {
|
||||
});
|
||||
|
||||
beforeAll(function () {
|
||||
});
|
||||
|
||||
test('global beforeAll execution order', function () {
|
||||
});
|
||||
|
||||
@ -1,11 +1,27 @@
|
||||
<?php
|
||||
|
||||
beforeEach(function (): void {
|
||||
expect($this->baz)->toBe(1); // set from Pest.php global/shared hook
|
||||
uses()->beforeEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('baz')
|
||||
->and($this->baz)
|
||||
->toBe(0);
|
||||
|
||||
$this->baz = 1;
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
expect($this)
|
||||
->toHaveProperty('baz')
|
||||
->and($this->baz)
|
||||
->toBe(1);
|
||||
|
||||
$this->baz = 2;
|
||||
});
|
||||
|
||||
test('global before each', function (): void {
|
||||
expect($this->baz)->toBe(2);
|
||||
test('global beforeEach execution order', function () {
|
||||
expect($this)
|
||||
->toHaveProperty('baz')
|
||||
->and($this->baz)
|
||||
->toBe(2);
|
||||
});
|
||||
|
||||
|
||||
@ -1,6 +1,19 @@
|
||||
<?php
|
||||
|
||||
uses()->group('integration')->in('Visual');
|
||||
uses()->beforeEach(function (): void {
|
||||
$this->baz = 1;
|
||||
})->in('Hooks');
|
||||
|
||||
uses()
|
||||
->beforeEach(function () {
|
||||
$this->baz = 0;
|
||||
})
|
||||
// ->beforeAll(function () {
|
||||
// dump(0);
|
||||
// })
|
||||
->afterEach(function () {
|
||||
$this->ith = 0;
|
||||
})
|
||||
// ->afterAll(function () {
|
||||
// dump(0);
|
||||
// })
|
||||
->in('Hooks');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user