Skip to content

Commit

Permalink
feat(tests): add beforeAll hook tests and update globalHook expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
laylatichy authored and gitbutler-client committed Nov 24, 2024
1 parent 1f8bc33 commit 488ee32
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
19 changes: 19 additions & 0 deletions tests/Hooks/BeforeAllTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

$_SERVER['beforeAllCalls'] = 0;

pest()->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);
});
4 changes: 3 additions & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down

0 comments on commit 488ee32

Please sign in to comment.