mirror of
https://github.com/pestphp/pest.git
synced 2026-03-12 02:37:22 +01:00
test: add cases for global before/after all hooks
This commit is contained in:
@ -1,10 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
uses()->afterAll(function () {
|
global $globalHook;
|
||||||
|
|
||||||
|
uses()->afterAll(function () use ($globalHook) {
|
||||||
|
expect($globalHook)
|
||||||
|
->toHaveProperty('afterAll')
|
||||||
|
->and($globalHook->afterAll)
|
||||||
|
->toBe(0);
|
||||||
|
|
||||||
|
$globalHook->afterAll = 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function () {
|
afterAll(function () use ($globalHook) {
|
||||||
|
expect($globalHook)
|
||||||
|
->toHaveProperty('afterAll')
|
||||||
|
->and($globalHook->afterAll)
|
||||||
|
->toBe(1);
|
||||||
|
|
||||||
|
$globalHook->afterAll = 2;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('global afterAll execution order', function () {
|
test('global afterAll execution order', function () use ($globalHook) {
|
||||||
|
expect($globalHook)
|
||||||
|
->not()
|
||||||
|
->toHaveProperty('afterAll');
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,10 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
uses()->beforeAll(function () {
|
global $globalHook;
|
||||||
|
|
||||||
|
uses()->beforeAll(function () use ($globalHook) {
|
||||||
|
expect($globalHook)
|
||||||
|
->toHaveProperty('beforeAll')
|
||||||
|
->and($globalHook->beforeAll)
|
||||||
|
->toBe(0);
|
||||||
|
|
||||||
|
$globalHook->beforeAll = 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeAll(function () {
|
beforeAll(function () use ($globalHook) {
|
||||||
|
expect($globalHook)
|
||||||
|
->toHaveProperty('beforeAll')
|
||||||
|
->and($globalHook->beforeAll)
|
||||||
|
->toBe(1);
|
||||||
|
|
||||||
|
$globalHook->beforeAll = 2;
|
||||||
});
|
});
|
||||||
|
|
||||||
test('global beforeAll execution order', function () {
|
test('global beforeAll execution order', function () use ($globalHook) {
|
||||||
|
expect($globalHook)
|
||||||
|
->toHaveProperty('beforeAll')
|
||||||
|
->and($globalHook->beforeAll)
|
||||||
|
->toBe(2);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,17 +2,19 @@
|
|||||||
|
|
||||||
uses()->group('integration')->in('Visual');
|
uses()->group('integration')->in('Visual');
|
||||||
|
|
||||||
|
$globalHook = (object) []; // NOTE: global test value container to be mutated and checked across files, as needed
|
||||||
|
|
||||||
uses()
|
uses()
|
||||||
->beforeEach(function () {
|
->beforeEach(function () {
|
||||||
$this->baz = 0;
|
$this->baz = 0;
|
||||||
})
|
})
|
||||||
// ->beforeAll(function () {
|
->beforeAll(function () use ($globalHook) {
|
||||||
// dump(0);
|
$globalHook->beforeAll = 0;
|
||||||
// })
|
})
|
||||||
->afterEach(function () {
|
->afterEach(function () {
|
||||||
$this->ith = 0;
|
$this->ith = 0;
|
||||||
})
|
})
|
||||||
// ->afterAll(function () {
|
->afterAll(function () use ($globalHook) {
|
||||||
// dump(0);
|
$globalHook->afterAll = 0;
|
||||||
// })
|
})
|
||||||
->in('Hooks');
|
->in('Hooks');
|
||||||
|
|||||||
Reference in New Issue
Block a user