chore: adjusts snapshots

This commit is contained in:
Nuno Maduro
2024-01-26 01:58:03 +00:00
parent a53a9d03cf
commit 19e748f0d4
4 changed files with 2 additions and 110 deletions

View File

@ -1,45 +0,0 @@
<?php
uses()->afterAll(function () {
expect($_SERVER['globalHook'])
->toHaveProperty('afterAll')
->and($_SERVER['globalHook']->afterAll)
->toBe(1)
->and($_SERVER['globalHook']->calls)
->afterAll
->toBe(1);
$_SERVER['globalHook']->afterAll = 2;
$_SERVER['globalHook']->calls->afterAll++;
});
afterAll(function () {
expect($_SERVER['globalHook'])
->toHaveProperty('afterAll')
->and($_SERVER['globalHook']->afterAll)
->toBe(1)
->and($_SERVER['globalHook']->calls)
->afterAll
->toBe(2);
$_SERVER['globalHook']->afterAll = 2;
$_SERVER['globalHook']->calls->afterAll++;
});
test('global afterAll execution order', function () {
expect($_SERVER['globalHook'])
->not()
->toHaveProperty('afterAll')
->and($_SERVER['globalHook']->calls)
->afterAll
->toBe(0);
});
it('only gets called once per file', function () {
expect($_SERVER['globalHook'])
->not()
->toHaveProperty('afterAll')
->and($_SERVER['globalHook']->calls)
->afterAll
->toBe(0);
});

View File

@ -1,55 +0,0 @@
<?php
use Pest\Plugins\Parallel;
use Pest\Support\Str;
// HACK: we have to determine our $_SERVER['globalHook-]>calls baseline. This is because
// two other tests are executed before this one due to filename ordering.
$args = $_SERVER['argv'] ?? [];
$single = (isset($args[1]) && Str::endsWith(__FILE__, $args[1])) || Parallel::isWorker();
$offset = $single ? 0 : 2;
uses()->beforeAll(function () use ($offset) {
expect($_SERVER['globalHook'])
->toHaveProperty('beforeAll')
->and($_SERVER['globalHook']->beforeAll)
->toBe(1)
->and($_SERVER['globalHook']->calls)
->beforeAll
->toBe(1 + $offset);
$_SERVER['globalHook']->beforeAll = 2;
$_SERVER['globalHook']->calls->beforeAll++;
});
beforeAll(function () use ($offset) {
expect($_SERVER['globalHook'])
->toHaveProperty('beforeAll')
->and($_SERVER['globalHook']->beforeAll)
->toBe(2)
->and($_SERVER['globalHook']->calls)
->beforeAll
->toBe(2 + $offset);
$_SERVER['globalHook']->beforeAll = 3;
$_SERVER['globalHook']->calls->beforeAll++;
});
test('global beforeAll execution order', function () use ($offset) {
expect($_SERVER['globalHook'])
->toHaveProperty('beforeAll')
->and($_SERVER['globalHook']->beforeAll)
->toBe(3)
->and($_SERVER['globalHook']->calls)
->beforeAll
->toBe(3 + $offset);
});
it('only gets called once per file', function () use ($offset) {
expect($_SERVER['globalHook'])
->beforeAll
->toBe(3)
->and($_SERVER['globalHook']->calls)
->beforeAll
->toBe(3 + $offset);
});