What Happened
I am trying to use the AfterAll() global hook to reset fixture data in a file.
What I expected was that the data would be reset.
What happens is nothing; the closure I set in Pest.php is never called.
If I set a breakpoint on the closure it is never reached.
By contrast, the BeforeAll() (which I use to initialise the fixture data), BeforeEach() and AfterEach() global hooks work as expected and pause on breakpoints when set.
How to Reproduce
In Pest.php
pest()->in('Feature') ->extend(TestCase::class) ->beforeAll(function () { TestCase::beforeAll(); }) ->afterAll(function () { TestCase::afterAll(); }) ;
In TestCase.php
`
abstract class TestCase extends BaseTestCase {
public static function afterAll(): void
{
// clear fixture - set a breakpoint here and it will not be hit
}
public static function beforeAll(): void
{
// initialise fixture - set a breakpoint here and it will be hit
}
}
`
Sample Repository
No response
Pest Version
pest: 4.7 & pest-plugin-browser: 4.3.1
PHP Version
8.5.3
Operation System
Linux
Notes
Looking in Testable::tearDownAfterClass() (I assuming this is the right place as the comment states that "This method is called after the last test of this Test Case is run."), $afterAll is an instance of Support/NullClosure.php; I kind of think it should be the closure I set in Pest.php.
What Happened
I am trying to use the AfterAll() global hook to reset fixture data in a file.
What I expected was that the data would be reset.
What happens is nothing; the closure I set in Pest.php is never called.
If I set a breakpoint on the closure it is never reached.
By contrast, the BeforeAll() (which I use to initialise the fixture data), BeforeEach() and AfterEach() global hooks work as expected and pause on breakpoints when set.
How to Reproduce
In Pest.php
pest()->in('Feature') ->extend(TestCase::class) ->beforeAll(function () { TestCase::beforeAll(); }) ->afterAll(function () { TestCase::afterAll(); }) ;In TestCase.php
`
abstract class TestCase extends BaseTestCase {
public static function afterAll(): void
{
// clear fixture - set a breakpoint here and it will not be hit
}
}
`
Sample Repository
No response
Pest Version
pest: 4.7 & pest-plugin-browser: 4.3.1
PHP Version
8.5.3
Operation System
Linux
Notes
Looking in Testable::tearDownAfterClass() (I assuming this is the right place as the comment states that "This method is called after the last test of this Test Case is run."), $afterAll is an instance of Support/NullClosure.php; I kind of think it should be the closure I set in Pest.php.