fix: before all

This commit is contained in:
Nuno Maduro
2025-07-25 20:54:37 -06:00
parent 6d6e4e040f
commit de4409e368
6 changed files with 34 additions and 7 deletions

View File

@ -1453,6 +1453,11 @@
✓ nested → nested afterEach execution order
✓ global afterEach execution order
PASS Tests\Hooks\BeforeAllTest
✓ it gets called before all tests 1 @ repetition 1 of 2
✓ it gets called before all tests 1 @ repetition 2 of 2
✓ it gets called before all tests 2
PASS Tests\Hooks\BeforeEachTest
✓ global beforeEach execution order
@ -1726,4 +1731,4 @@
WARN Tests\Visual\Version
- visual snapshot of help command output
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1154 passed (2754 assertions)
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 33 skipped, 1157 passed (2766 assertions)

View File

@ -0,0 +1,16 @@
<?php
pest()->beforeAll(function () {
expect($_SERVER['globalHook']->calls->beforeAll)
->toBe(0);
$_SERVER['globalHook']->calls->beforeAll++;
});
it('gets called before all tests 1', function () {
expect($_SERVER['globalHook']->calls->beforeAll)->toBe(1);
})->repeat(2);
it('gets called before all tests 2', function () {
expect($_SERVER['globalHook']->calls->beforeAll)->toBe(1);
});

View File

@ -29,7 +29,6 @@ pest()
})
->beforeAll(function () {
$_SERVER['globalHook']->beforeAll = 0;
$_SERVER['globalHook']->calls->beforeAll++;
})
->afterEach(function () {
if (! isset($this->ith)) {

View File

@ -16,7 +16,7 @@ $run = function () {
test('parallel', function () use ($run) {
expect($run('--exclude-group=integration'))
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 24 skipped, 1144 passed (2730 assertions)')
->toContain('Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 38 todos, 24 skipped, 1147 passed (2742 assertions)')
->toContain('Parallel: 3 processes');
})->skipOnWindows();