From 1a8337c2d5b0f8222dcc5f97b3f2f39bb61b1018 Mon Sep 17 00:00:00 2001 From: Layla Tichy Date: Sun, 24 Nov 2024 08:23:08 +0000 Subject: [PATCH] feat(tests): add beforeAll hook tests and update globalHook expectations --- tests/Hooks/BeforeAllTest.php | 19 +++++++++++++++++++ tests/Pest.php | 4 +++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tests/Hooks/BeforeAllTest.php diff --git a/tests/Hooks/BeforeAllTest.php b/tests/Hooks/BeforeAllTest.php new file mode 100644 index 000000000..553390d3e --- /dev/null +++ b/tests/Hooks/BeforeAllTest.php @@ -0,0 +1,19 @@ +beforeAll(function () { + $_SERVER['beforeAllCalls']++; + + expect($_SERVER['beforeAllCalls'])->toBe(1); +}); + +beforeAll(function () { + $_SERVER['beforeAllCalls']++; + + expect($_SERVER['beforeAllCalls'])->toBe(2); +}); + +test('beforeAll is called', function () { + expect($_SERVER['beforeAllCalls'])->toBe(2); +}); diff --git a/tests/Pest.php b/tests/Pest.php index a938fc7e4..13f9956c5 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -73,7 +73,9 @@ expect($_SERVER['globalHook']) ->toHaveProperty('afterAll') ->and($_SERVER['globalHook']->afterAll) - ->toBe(0); + ->toBe(0) + ->and($_SERVER['beforeAll']) + ->toBe(1); $_SERVER['globalHook']->afterAll = 1; });