InteractsWithTestCaseLifecycle
trait InteractsWithTestCaseLifecycle
Properties
| protected Application|null | $app | The application instance. |
|
| protected array | $afterApplicationCreatedCallbacks | The callbacks that should be run after the application is created. |
|
| protected array | $beforeApplicationDestroyedCallbacks | The callbacks that should be run before the application is destroyed. |
|
| protected Throwable|null | $callbackException | The exception thrown while running an application destruction callback. |
|
| protected bool | $setUpHasRun | Indicates if we have made it through the base setUp function. |
Methods
Set up the test environment.
Clean up the testing environment before the next test.
Boot the testing helper traits.
Set up database-related testing traits.
Clean up the testing environment before the next test case.
Register a callback to be run after the application is created.
Register a callback to be run before the application is destroyed.
Execute the application's pre-destruction callbacks.
Preserve transaction manager context for the test coroutine.
Ensure callback is executed in coroutine.
Details
at line 62
protected void
setUpTheTestEnvironment()
| internal |
Set up the test environment.
at line 101
protected void
tearDownTheTestEnvironment()
| internal |
Clean up the testing environment before the next test.
at line 180
protected array
setUpTraits()
Boot the testing helper traits.
at line 227
protected void
setUpDatabaseTraits(array $uses)
Set up database-related testing traits.
Override this method to customize database trait initialization order, e.g. to process test attributes before migrations run.
at line 251
static void
tearDownAfterClassUsingTestCase()
| internal |
Clean up the testing environment before the next test case.
at line 264
afterApplicationCreated(callable $callback)
Register a callback to be run after the application is created.
at line 276
protected
beforeApplicationDestroyed(callable $callback)
Register a callback to be run before the application is destroyed.
at line 284
protected
callBeforeApplicationDestroyedCallbacks()
Execute the application's pre-destruction callbacks.
at line 305
protected void
preserveTransactionContext()
Preserve transaction manager context for the test coroutine.
RefreshDatabase and DatabaseTransactions store transaction state in Context. Since setUpTraits runs in a temporary coroutine (separate from the test method's coroutine), we must copy this state to non-coroutine context. The test coroutine will then copy from non-coroutine context via copyFromNonCoroutine().
at line 316
protected void
runInCoroutine(callable $callback)
Ensure callback is executed in coroutine.
Exceptions are captured and re-thrown outside the coroutine context so they propagate correctly to PHPUnit (e.g., for markTestSkipped).