Files
pest/tests/Pest.php
jordanbrauer 79ff332afe test: global "all" hooks must only run once (#351)
in other words, they can only run once per file
2021-07-21 20:32:39 -05:00

24 lines
632 B
PHP

<?php
uses()->group('integration')->in('Visual');
// NOTE: global test value container to be mutated and checked across files, as needed
$globalHook = (object) ['calls' => (object) ['beforeAll' => 0, 'afterAll' => 0]];
uses()
->beforeEach(function () {
$this->baz = 0;
})
->beforeAll(function () use ($globalHook) {
$globalHook->beforeAll = 0;
$globalHook->calls->beforeAll++;
})
->afterEach(function () {
$this->ith = 0;
})
->afterAll(function () use ($globalHook) {
$globalHook->afterAll = 0;
$globalHook->calls->afterAll++;
})
->in('Hooks');