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 | $afterApplicationRefreshedCallbacks | The callbacks that should be run after the application is refreshed. |
|
| 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. |
|
| protected bool | $afterApplicationRefreshedCallbacksStarted | Indicates if the application refreshed callbacks have started running. |
Methods
Set up the test environment.
Clean up the testing environment before the next test.
Reset static state between test executions.
Boot the testing helper traits.
Determine if the trait should be skipped when setting up the test environment.
Set up database-related testing traits.
Forget retained migration state when a selected in-memory database is missing.
Clean up the testing environment before the next test case.
Register a callback to be run after the application is refreshed.
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 72
protected void
setUpTheTestEnvironment()
| internal |
Set up the test environment.
at line 116
protected void
tearDownTheTestEnvironment()
| internal |
Clean up the testing environment before the next test.
at line 187
protected void
flushState()
Reset static state between test executions.
at line 196
protected array
setUpTraits()
Boot the testing helper traits.
at line 246
protected bool
setUpTheTestEnvironmentTraitToBeIgnored(string $use)
Determine if the trait should be skipped when setting up the test environment.
at line 257
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 281
protected void
forgetStaleMigrationState(array $uses)
Forget retained migration state when a selected in-memory database is missing.
at line 301
static void
tearDownAfterClassUsingTestCase()
| internal |
Clean up the testing environment before the next test case.
at line 310
void
afterApplicationRefreshed(callable $callback)
Register a callback to be run after the application is refreshed.
The callbacks run before the test case's traits are set up, and again for each reloaded application.
at line 322
void
afterApplicationCreated(callable $callback)
Register a callback to be run after the application is created.
at line 334
protected void
beforeApplicationDestroyed(callable $callback)
Register a callback to be run before the application is destroyed.
at line 342
protected void
callBeforeApplicationDestroyedCallbacks()
Execute the application's pre-destruction callbacks.
at line 364
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 restores the same transaction state explicitly; normal context copying omits it so child coroutines cannot inherit their parent's transactions.
at line 375
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).