TestCase
class TestCase extends TestCase implements TestCase
Base test case for package testing with testbench features.
Methods below are provided by traits that child test classes may use. The setUpTraits() method checks for trait usage before calling these.
Traits
Composes the Testbench testing concerns into a single upstream-facing trait.
Creates and bootstraps the application for testbench tests.
Handles parsing and executing test method attributes.
Provides per-worker database isolation for parallel testing.
Properties
| protected Vite|null | $originalVite | The original Vite handler. |
from InteractsWithContainer |
| protected DeferredCallbackCollection|null | $originalDeferredCallbacksCollection | The original deferred callbacks collection. |
from InteractsWithContainer |
| protected array | $defaultHeaders | Additional headers for the request. |
from MakesHttpRequests |
| protected array | $defaultCookies | Additional cookies for the request. |
from MakesHttpRequests |
| protected array | $unencryptedCookies | Additional cookies that will not be encrypted for the request. |
from MakesHttpRequests |
| protected array | $serverVariables | Additional server variables for the request. |
from MakesHttpRequests |
| protected bool | $followRedirects | Indicates whether redirects should be followed. |
from MakesHttpRequests |
| protected bool | $encryptCookies | Indicates whether cookies should be encrypted. |
from MakesHttpRequests |
| protected bool | $withCredentials | Indicated whether JSON requests should be performed "with credentials" (cookies). |
from MakesHttpRequests |
| static protected Waiter|null | $waiter | The coroutine waiter for test requests. |
from MakesHttpRequests |
| bool | $mockConsoleOutput | Indicates if the console output should be mocked. |
from InteractsWithConsole |
| bool|null | $expectsOutput | Indicates if the command is expected to output anything. |
from InteractsWithConsole |
| array | $expectedOutput | All of the expected output lines. |
from InteractsWithConsole |
| array | $expectedOutputSubstrings | All of the expected text to be present in the output. |
from InteractsWithConsole |
| array | $unexpectedOutput | All of the output lines that aren't expected to be displayed. |
from InteractsWithConsole |
| array | $unexpectedOutputSubstrings | All of the text that is not expected to be present in the output. |
from InteractsWithConsole |
| array | $expectedQuestions | All of the expected questions. |
from InteractsWithConsole |
| array | $expectedChoices | All of the expected choice questions. |
from InteractsWithConsole |
| protected mixed | $originalDeprecationHandler | The original deprecation handler. |
from InteractsWithDeprecationHandling |
| protected ExceptionHandler|null | $originalExceptionHandler | The original exception handler. |
from InteractsWithExceptionHandling |
| protected Application|null | $app | The application instance. |
from InteractsWithTestCaseLifecycle |
| protected array | $afterApplicationCreatedCallbacks | The callbacks that should be run after the application is created. |
from InteractsWithTestCaseLifecycle |
| protected array | $afterApplicationRefreshedCallbacks | The callbacks that should be run after the application is refreshed. |
from InteractsWithTestCaseLifecycle |
| protected array | $beforeApplicationDestroyedCallbacks | The callbacks that should be run before the application is destroyed. |
from InteractsWithTestCaseLifecycle |
| protected Throwable|null | $callbackException | The exception thrown while running an application destruction callback. |
from InteractsWithTestCaseLifecycle |
| protected bool | $setUpHasRun | Indicates if we have made it through the base setUp function. |
from InteractsWithTestCaseLifecycle |
| protected bool | $afterApplicationRefreshedCallbacksStarted | Indicates if the application refreshed callbacks have started running. |
from InteractsWithTestCaseLifecycle |
| protected array | $firedEvents | All of the fired events. |
from MocksApplicationServices |
| protected bool | $runTestsInCoroutine | from RunTestsInCoroutine | |
| protected bool | $copyNonCoroutineContext | from RunTestsInCoroutine | |
| protected Throwable|null | $exceptionOutlivedByChildCoroutines | The exception the test threw before its child coroutines reached the time limit. |
from RunTestsInCoroutine |
| protected Generator|null | $faker | The Faker instance. |
from WithFaker |
| protected array<string, string> | $traitsUsedByTest | The traits used by the test case, including inherited traits. |
from TestCase |
| protected bool|null | $withoutBootingFramework | Memoized result of the withoutBootingFramework check. |
from TestCase |
| static protected array<class-string, array<class-string, class-string>> | $cachedTestCaseUses | Cached traits used by each test case class. |
from InteractsWithTestCase |
| static protected array<int, array{key: class-string, instance: object}> | $testCaseTestingFeatures | Programmatically added class-level testing features. |
from InteractsWithTestCase |
| static protected array<int, array{key: class-string, instance: object}> | $testCaseMethodTestingFeatures | Programmatically added method-level testing features. |
from InteractsWithTestCase |
| protected null|Closure): void | $testCaseSetUpCallback | The cached test case setUp resolver. |
from InteractsWithPHPUnit |
| protected null|Closure): void | $testCaseTearDownCallback | The cached test case tearDown resolver. |
from InteractsWithPHPUnit |
| static protected array<string, array<int, array{key: class-string, instance: object}>> | $cachedTestCaseClassAttributes | Cached class attributes by class name. |
from InteractsWithPHPUnit |
| static protected array<string, array<int, array{key: class-string, instance: object}>> | $cachedTestCaseMethodAttributes | Cached method attributes by "class:method" key. |
from InteractsWithPHPUnit |
| protected string|false|null | $applicationBootstrapFile | The resolved application bootstrap file. |
from WithHypervelBootstrapFile |
| null|bool | $enablesPackageDiscoveries | from CreatesApplication | |
| protected bool | $loadEnvironmentVariables | Automatically loads environment variables when available. |
|
| protected bool | $syncTestbenchRoutesHasRun | Whether Testbench routes have been synchronized for this test. |
from HandlesRoutes |
| protected bool | $testbenchRouteCleanupRegistered | Whether route file cleanup has been registered for this test. |
from HandlesRoutes |
| protected bool | $reloadingApplicationForCachedRoutes | Whether defineCacheRoutes() is reloading the application to load cached routes. |
from HandlesRoutes |
| protected array<int, string> | $testbenchRouteFiles | Route files written by this test instance. |
from HandlesRoutes |
| protected MigrateProcessor> | $cachedTestMigratorProcessors | List of cached migrators instances. |
from InteractsWithMigrations |
| protected string | $baseUrl | The base URL to use while testing the application. |
Methods
Register an instance in the container.
Register an instance in the container.
Mock a partial instance of an object in the container.
Instruct the container to forget a previously mocked / spied instance of an object.
Register a Vite handler that returns empty strings for all assets.
Return empty asset markup.
Return an empty result for dynamic calls.
Ignore integrity key configuration.
Ignore build directory configuration.
Ignore hot file configuration.
Ignore entry point configuration.
Ignore script tag attributes.
Ignore style tag attributes.
Ignore preload tag attributes.
Return empty asset content.
Return an empty asset URL.
Define additional headers to be sent with the request.
Add a header to be sent with the request.
Remove a header from the request.
Remove headers from the request.
Add an authorization token for the request.
Add a basic authentication header to the request with the given credentials.
Remove the authorization token from the request.
Define a set of server variables to be sent with the requests.
Disable middleware for the test.
Enable the given middleware for the test.
Define additional cookies to be sent with the request.
Add a cookie to be sent with the request.
Define additional cookies that will not be encrypted before sending with the request.
Add a cookie that will not be encrypted before sending with the request.
Automatically follow any redirects returned from the response.
Include cookies and authorization headers for JSON requests.
Disable automatic encryption of cookie values.
Set the referer header and previous URL session value in order to simulate a previous request.
Set the referer header and previous URL session value from a given route in order to simulate a previous request.
Visit the given URI with a GET request, expecting a JSON response.
Visit the given URI with a POST request.
Visit the given URI with a POST request, expecting a JSON response.
Visit the given URI with a PUT request.
Visit the given URI with a PUT request, expecting a JSON response.
Visit the given URI with a PATCH request.
Visit the given URI with a PATCH request, expecting a JSON response.
Visit the given URI with a DELETE request.
Visit the given URI with a DELETE request, expecting a JSON response.
Visit the given URI with an OPTIONS request.
Visit the given URI with an OPTIONS request, expecting a JSON response.
Visit the given URI with a QUERY request.
Visit the given URI with a QUERY request, expecting a JSON response.
Call the given URI with a JSON request.
Call the given URI and return the Response.
Sync durable request Context state to the test coroutine.
Get a snapshot of durable session Context state for the completed request.
Transform headers array to array of $SERVER vars with HTTP* format.
Format the header name for the server array.
Extract the file uploads from the given data array.
If enabled, encrypt cookie values for request.
Follow a redirect chain until a non-redirect is received.
Create the request instance used for testing from the given Symfony request.
Create the test response instance from the given response.
Dispatch a request lifecycle event if enabled.
Set the currently logged in user for the application.
Clear the currently logged in user for the application.
Set the currently logged in user for the application.
Assert that the user is authenticated.
Assert that the user is not authenticated.
Return true if the user is authenticated, false otherwise.
Assert that the user is authenticated as the given user.
Assert that the given credentials are valid.
Assert that the given credentials are invalid.
Return true if the credentials are valid, false otherwise.
Invoke an Artisan command and return a mocked pending command or exit code.
Invoke an Artisan command and return a mocked pending command.
Invoke an Artisan command and return the exit code.
Disable mocking the console output.
Assert that a given where condition exists in the database.
Assert that a given where condition does not exist in the database.
Assert the count of table entries.
Assert that the given table or tables has no entries.
Assert the given record has been "soft deleted".
Assert the given record has not been "soft deleted".
Assert the given model does not exist in the database.
Specify the number of database queries that should occur throughout the test.
Determine if the argument is a soft deletable model.
Cast a JSON string to a database compatible type.
Get the database connection.
Get the table column name used for soft deletes.
Seed a given database connection.
Restore deprecation handling.
Disable deprecation handling for the test.
Set an environment variable for the current PHP process.
Unset an environment variable for the current PHP process.
Run a callback with a temporary environment variable value.
Run a callback with temporary environment variable values.
Get the class name of the first parameter of the given Closure.
Get the class names of the first parameter of the given Closure, including union types.
Get the class names / types of the parameters of the given Closure.
Get the class names / types of the return type of the given Closure.
Restore exception handling.
Only handle the given exceptions via the exception handler.
Only handle validation exceptions via the exception handler.
Disable exception handling for the test.
Create a new exception handler instance.
Register a callback to be called after an HTTP error response is rendered.
Assert route middleware runtime order.
Get resolved runtime middleware for a named route.
Set the session to the given array.
Set the session to the given array.
Start the session for the application.
Flush all of the current session data.
Freeze time at the beginning of the current second.
Travel to another time.
Clean up the testing environment before the next test.
Skip Workbench's convention hook because it runs before database setup.
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.
Render the contents of the given Blade template string.
Populate the shared view error bag with the given errors.
Specify a list of events that should be fired for the given operation.
Specify a list of events that should not be fired for the given operation.
Mock the event dispatcher so all events are silenced and collected.
Filter the given events against the fired events.
Filter the given classes against an array of dispatched classes.
Check if the given class exists in an array of dispatched classes.
Invoke the test method inside a Swoole coroutine container.
Enforce PHPUnit's deadline while the test or its children are suspended.
Fail a test whose expected exception was followed by child coroutines reaching the time limit.
Determine if framework lifecycle hooks should run for this test.
Run trait and test setup hooks in the test coroutine.
Run test and trait teardown hooks while capturing failures.
Clear transaction context from non-coroutine storage before test starts.
Tear down the testing environment using Mockery.
Get the default Faker instance for a given locale.
Create a Faker instance for the given locale.
Setup the test environment.
Refresh the application instance.
Prepare the application to reuse cached test state.
Clean up the testing environment before the next test.
Determine if the test method should run without booting the framework.
Clean up the testing environment before the next test case.
Rewrite the default connection's database name for parallel testing.
Ensure the per-worker database exists, creating it if needed.
Determine if the database should be managed for parallel testing.
Get the per-worker test database name.
Determine if the test case uses the given trait, or the Testing trait by default.
Determine if the test case uses refresh-database testing concerns.
Cache and return traits used by test case.
Programmatically add a testing feature attribute.
Resolve PHPUnit method attributes for specific method.
Execute BeforeEach lifecycle attributes.
Execute AfterEach lifecycle attributes.
Load test fixtures and execute BeforeAll lifecycle attributes.
Determine if the object is running as a PHPUnit test case.
Resolve the PHPUnit test class name.
Resolve the PHPUnit test method name.
Resolve and cache PHPUnit attributes for current test.
Cache uses for test case before class runs.
Clear PHPUnit caches after class teardown.
Determine if the trait is used within testing using Pest.
Determine if the object implements Pest test runner.
Get Application's base path.
Ignore package discovery from.
Resolve application Console Kernel implementation.
Get application HTTP Kernel implementation using Workbench.
Get application HTTP exception handler using Workbench.
Get the cached Workbench configuration.
Get application bootstrap file path (if exists).
Determine if application is using a custom application kernels.
Determine if application is bootstrapped using Testbench's default skeleton.
Create the default application implementation.
Make a relative COMPOSER_VENDOR_DIR from the application environment absolute.
Mask inherited framework APP_ENV for Testbench applications that opt out of loading env files.
Determine if the current test explicitly configured an environment variable.
Resolve application console kernel implementation.
Load configuration and register package providers/aliases.
Resolve the route provider from application provider overrides.
Run bootstrappers individually with defineEnvironment() inserted.
Refresh route name lookups now and whenever the URL generator is resolved.
Configure worker-specific cache paths for parallel testing.
Get the current ParaTest worker token before the application exists.
Terminate and flush an application, returning any cleanup failure.
Mark the test as skipped when condition is not equivalent to true.
Mark the test as skipped when condition is equivalent to true.
Parse and execute test method attributes of a specific type.
Determine if using in-memory SQLite database connection.
Define database migrations after database refreshed.
Register cleanup for route files and route cache written by this test.
Get a route file path owned by this test instance.
Define hooks to migrate the database before and after each test.
Determine whether migration paths should be registered for an upcoming migration.
Resolve Package Migrations Artisan command options.
Migrate Hypervel's default migrations.
Migrate all Hypervel migrations.
Resolve Hypervel Migrations Artisan command options.
Run and retain a migration processor for teardown.
Determine whether the active database concerns retain in-memory state.
Set up the Testbench environment.
Preserve the package manifest cache for the duration of the test.
Isolate method-specific migration sets from the retained truncation schema.
Clean up the Testbench environment.
Prepare the testing environment before the running the test case.
No description
No description
No description
No description
No description
No description
Details
in
InteractsWithContainer at line 35
protected mixed
swap(string $abstract, mixed $instance)
Register an instance in the container.
in
InteractsWithContainer at line 48
protected mixed
instance(string $abstract, mixed $instance)
Register an instance in the container.
in
InteractsWithContainer at line 63
protected MockInterface
mock(string $abstract, Closure|null $mock = null)
Mock an instance of an object in the container.
in
InteractsWithContainer at line 76
protected MockInterface
partialMock(string $abstract, Closure|null $mock = null)
Mock a partial instance of an object in the container.
in
InteractsWithContainer at line 89
protected MockInterface
spy(string $abstract, Closure|null $mock = null)
Spy an instance of an object in the container.
in
InteractsWithContainer at line 99
protected InteractsWithContainer
forgetMock(string $abstract)
Instruct the container to forget a previously mocked / spied instance of an object.
in
InteractsWithContainer at line 111
protected InteractsWithContainer
withoutVite()
Register a Vite handler that returns empty strings for all assets.
in
InteractsWithContainer at line 123
HtmlString
__invoke(string|array $entrypoints, string|null $buildDirectory = null)
Return empty asset markup.
in
InteractsWithContainer at line 131
mixed
__call(string $method, array $parameters)
Return an empty result for dynamic calls.
in
InteractsWithContainer at line 139
string
__toString()
Return empty asset markup as a string.
in
InteractsWithContainer at line 147
InteractsWithContainer
useIntegrityKey(string|false $key)
Ignore integrity key configuration.
in
InteractsWithContainer at line 155
InteractsWithContainer
useBuildDirectory(string $path)
Ignore build directory configuration.
in
InteractsWithContainer at line 163
InteractsWithContainer
useHotFile(string $path)
Ignore hot file configuration.
in
InteractsWithContainer at line 171
InteractsWithContainer
withEntryPoints(array $entryPoints)
Ignore entry point configuration.
in
InteractsWithContainer at line 179
InteractsWithContainer
useScriptTagAttributes(array|callable $attributes)
Ignore script tag attributes.
in
InteractsWithContainer at line 187
InteractsWithContainer
useStyleTagAttributes(array|callable $attributes)
Ignore style tag attributes.
in
InteractsWithContainer at line 195
InteractsWithContainer
usePreloadTagAttributes(array|callable|false $attributes)
Ignore preload tag attributes.
in
InteractsWithContainer at line 203
array
preloadedAssets()
Return an empty list of preloaded assets.
in
InteractsWithContainer at line 211
HtmlString
reactRefresh()
Return empty React refresh markup.
in
InteractsWithContainer at line 219
string
content(string $asset, string|null $buildDirectory = null)
Return empty asset content.
in
InteractsWithContainer at line 227
string
asset(string $asset, string|null $buildDirectory = null)
Return an empty asset URL.
in
MakesHttpRequests at line 80
MakesHttpRequests
withHeaders(array $headers)
Define additional headers to be sent with the request.
in
MakesHttpRequests at line 92
MakesHttpRequests
withHeader(string $name, string $value)
Add a header to be sent with the request.
in
MakesHttpRequests at line 104
MakesHttpRequests
withoutHeader(string $name)
Remove a header from the request.
in
MakesHttpRequests at line 116
MakesHttpRequests
withoutHeaders(array $headers)
Remove headers from the request.
in
MakesHttpRequests at line 130
MakesHttpRequests
withToken(string $token, string $type = 'Bearer')
Add an authorization token for the request.
in
MakesHttpRequests at line 140
MakesHttpRequests
withBasicAuth(string $username, string $password)
Add a basic authentication header to the request with the given credentials.
in
MakesHttpRequests at line 150
MakesHttpRequests
withoutToken()
Remove the authorization token from the request.
in
MakesHttpRequests at line 160
MakesHttpRequests
flushHeaders()
Flush all the configured headers.
in
MakesHttpRequests at line 172
MakesHttpRequests
withServerVariables(array $server)
Define a set of server variables to be sent with the requests.
in
MakesHttpRequests at line 185
MakesHttpRequests
withoutMiddleware(null|array|string $middleware = null)
Disable middleware for the test.
in
MakesHttpRequests at line 206
MakesHttpRequests
withMiddleware(null|array|string $middleware = null)
Enable the given middleware for the test.
in
MakesHttpRequests at line 226
MakesHttpRequests
withCookies(array $cookies)
Define additional cookies to be sent with the request.
in
MakesHttpRequests at line 238
MakesHttpRequests
withCookie(string $name, string $value)
Add a cookie to be sent with the request.
in
MakesHttpRequests at line 250
MakesHttpRequests
withUnencryptedCookies(array $cookies)
Define additional cookies that will not be encrypted before sending with the request.
in
MakesHttpRequests at line 262
MakesHttpRequests
withUnencryptedCookie(string $name, string $value)
Add a cookie that will not be encrypted before sending with the request.
in
MakesHttpRequests at line 274
MakesHttpRequests
followingRedirects()
Automatically follow any redirects returned from the response.
in
MakesHttpRequests at line 286
MakesHttpRequests
withCredentials()
Include cookies and authorization headers for JSON requests.
in
MakesHttpRequests at line 298
MakesHttpRequests
disableCookieEncryption()
Disable automatic encryption of cookie values.
in
MakesHttpRequests at line 310
MakesHttpRequests
from(string $url)
Set the referer header and previous URL session value in order to simulate a previous request.
in
MakesHttpRequests at line 322
MakesHttpRequests
fromRoute(BackedEnum|string $name, mixed $parameters = [])
Set the referer header and previous URL session value from a given route in order to simulate a previous request.
in
MakesHttpRequests at line 332
MakesHttpRequests
withPrecognition()
Set the Precognition header to "true".
in
MakesHttpRequests at line 340
TestResponse
get(Stringable|string $uri, array $headers = [])
Visit the given URI with a GET request.
in
MakesHttpRequests at line 351
TestResponse
getJson(Stringable|string $uri, array $headers = [], int $options = 0)
Visit the given URI with a GET request, expecting a JSON response.
in
MakesHttpRequests at line 359
TestResponse
post(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a POST request.
in
MakesHttpRequests at line 370
TestResponse
postJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a POST request, expecting a JSON response.
in
MakesHttpRequests at line 378
TestResponse
put(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a PUT request.
in
MakesHttpRequests at line 389
TestResponse
putJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a PUT request, expecting a JSON response.
in
MakesHttpRequests at line 397
TestResponse
patch(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a PATCH request.
in
MakesHttpRequests at line 408
TestResponse
patchJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a PATCH request, expecting a JSON response.
in
MakesHttpRequests at line 416
TestResponse
delete(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a DELETE request.
in
MakesHttpRequests at line 427
TestResponse
deleteJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a DELETE request, expecting a JSON response.
in
MakesHttpRequests at line 435
TestResponse
options(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with an OPTIONS request.
in
MakesHttpRequests at line 446
TestResponse
optionsJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with an OPTIONS request, expecting a JSON response.
in
MakesHttpRequests at line 454
TestResponse
head(Stringable|string $uri, array $headers = [])
Visit the given URI with a HEAD request.
in
MakesHttpRequests at line 465
TestResponse
query(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a QUERY request.
in
MakesHttpRequests at line 476
TestResponse
queryJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Visit the given URI with a QUERY request, expecting a JSON response.
in
MakesHttpRequests at line 488
TestResponse
json(string $method, Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)
Call the given URI with a JSON request.
in
MakesHttpRequests at line 519
TestResponse
call(string $method, Stringable|string $uri, array $parameters = [], array $cookies = [], array $files = [], array $server = [], string|null $content = null)
Call the given URI and return the Response.
Each test request runs in a fresh coroutine via the Waiter to ensure coroutine-local Context isolation. RequestContext is seeded because tests bypass the HttpServer\Server adapter which normally does this in onRequest().
in
MakesHttpRequests at line 616
protected string
prepareUrlForRequest(Stringable|string $uri)
Turn the given URI into a fully-qualified URL.
in
MakesHttpRequests at line 630
protected void
syncRequestContextToParent(Request $request)
Sync durable request Context state to the test coroutine.
in
MakesHttpRequests at line 651
protected array
sessionContextSnapshot(Request $request)
Get a snapshot of durable session Context state for the completed request.
in
MakesHttpRequests at line 674
protected array
sessionContextKeys()
Get durable session Context keys.
in
MakesHttpRequests at line 693
protected array
sessionStoreContextKeys(Store $session)
Get the Context keys for the given session store.
in
MakesHttpRequests at line 709
protected array
authenticationContextKeys()
Get durable authentication Context keys.
in
MakesHttpRequests at line 727
protected array
transformHeadersToServerVars(array $headers)
Transform headers array to array of $SERVER vars with HTTP* format.
in
MakesHttpRequests at line 739
protected string
formatServerHeaderKey(string $name)
Format the header name for the server array.
in
MakesHttpRequests at line 751
protected array
extractFilesFromDataArray(array $data)
Extract the file uploads from the given data array.
in
MakesHttpRequests at line 775
protected array
prepareCookiesForRequest()
If enabled, encrypt cookie values for request.
in
MakesHttpRequests at line 790
protected array
prepareCookiesForJsonRequest()
Prepare cookies for JSON requests.
in
MakesHttpRequests at line 799
protected TestResponse
followRedirects(mixed $response)
Follow a redirect chain until a non-redirect is received.
in
MakesHttpRequests at line 813
protected Request
createTestRequest(Request $symfonyRequest)
Create the request instance used for testing from the given Symfony request.
in
MakesHttpRequests at line 822
protected TestResponse
createTestResponse(mixed $response, Request|null $request = null)
Create the test response instance from the given response.
in
MakesHttpRequests at line 839
protected void
dispatchRequestLifecycleEvent(string $eventClass, Request $request, Response|null $response = null)
Dispatch a request lifecycle event if enabled.
Tests bypass the HttpServer\Server adapter, so lifecycle events must be dispatched here for Telescope and other watchers to work in test contexts.
in
MakesHttpRequests at line 864
protected Waiter
getWaiter()
Get the coroutine waiter for test requests.
in
InteractsWithAuthentication at line 16
InteractsWithAuthentication
actingAs(Authenticatable $user, string|null $guard = null)
Set the currently logged in user for the application.
in
InteractsWithAuthentication at line 26
InteractsWithAuthentication
actingAsGuest(string|null $guard = null)
Clear the currently logged in user for the application.
in
InteractsWithAuthentication at line 42
InteractsWithAuthentication
be(Authenticatable $user, string|null $guard = null)
Set the currently logged in user for the application.
in
InteractsWithAuthentication at line 62
InteractsWithAuthentication
assertAuthenticated(string|null $guard = null)
Assert that the user is authenticated.
in
InteractsWithAuthentication at line 74
InteractsWithAuthentication
assertGuest(string|null $guard = null)
Assert that the user is not authenticated.
in
InteractsWithAuthentication at line 84
protected bool
isAuthenticated(string|null $guard = null)
Return true if the user is authenticated, false otherwise.
in
InteractsWithAuthentication at line 94
InteractsWithAuthentication
assertAuthenticatedAs(Authenticatable $user, string|null $guard = null)
Assert that the user is authenticated as the given user.
in
InteractsWithAuthentication at line 120
InteractsWithAuthentication
assertCredentials(array $credentials, string|null $guard = null)
Assert that the given credentials are valid.
in
InteractsWithAuthentication at line 135
InteractsWithAuthentication
assertInvalidCredentials(array $credentials, string|null $guard = null)
Assert that the given credentials are invalid.
in
InteractsWithAuthentication at line 148
protected bool
hasCredentials(array $credentials, string|null $guard = null)
Return true if the credentials are valid, false otherwise.
in
InteractsWithConsole at line 55
int|PendingCommand
artisan(string $command, array $parameters = [])
Invoke an Artisan command and return a mocked pending command or exit code.
in
InteractsWithConsole at line 65
PendingCommand
mockArtisan(string $command, array $parameters = [])
Invoke an Artisan command and return a mocked pending command.
in
InteractsWithConsole at line 73
int
realArtisan(string $command, array $parameters = [])
Invoke an Artisan command and return the exit code.
in
InteractsWithConsole at line 88
protected InteractsWithConsole
withoutMockingConsoleOutput()
Disable mocking the console output.
When using this with traits like DatabaseMigrations, call this in setUp() before parent::setUp() to ensure mock output is never bound.
in
InteractsWithDatabase at line 31
protected InteractsWithDatabase
assertDatabaseHas(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null)
Assert that a given where condition exists in the database.
in
InteractsWithDatabase at line 71
protected InteractsWithDatabase
assertDatabaseMissing(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null)
Assert that a given where condition does not exist in the database.
in
InteractsWithDatabase at line 111
protected InteractsWithDatabase
assertDatabaseCount(iterable|Model|string $table, int|null $count = null, UnitEnum|string|null $connection = null)
Assert the count of table entries.
in
InteractsWithDatabase at line 135
protected InteractsWithDatabase
assertDatabaseEmpty(iterable|Model|string $table, UnitEnum|string|null $connection = null)
Assert that the given table or tables has no entries.
in
InteractsWithDatabase at line 160
protected InteractsWithDatabase
assertSoftDeleted(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null, string|null $deletedAtColumn = 'deleted_at')
Assert the given record has been "soft deleted".
in
InteractsWithDatabase at line 207
protected InteractsWithDatabase
assertNotSoftDeleted(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null, string|null $deletedAtColumn = 'deleted_at')
Assert the given record has not been "soft deleted".
in
InteractsWithDatabase at line 253
protected InteractsWithDatabase
assertModelExists(iterable|Model|string $model)
Assert the given model exists in the database.
in
InteractsWithDatabase at line 264
protected InteractsWithDatabase
assertModelMissing(iterable|Model|string $model)
Assert the given model does not exist in the database.
in
InteractsWithDatabase at line 274
InteractsWithDatabase
expectsDatabaseQueryCount(int $expected, UnitEnum|string|null $connection = null)
Specify the number of database queries that should occur throughout the test.
in
InteractsWithDatabase at line 302
protected bool
isSoftDeletableModel(mixed $model)
Determine if the argument is a soft deletable model.
in
InteractsWithDatabase at line 310
Expression
castAsJson(array|object|string $value, UnitEnum|string|null $connection = null)
Cast a JSON string to a database compatible type.
in
InteractsWithDatabase at line 332
protected Connection
getConnection(UnitEnum|string|null $connection = null, Model|string|null $table = null)
Get the database connection.
in
InteractsWithDatabase at line 354
protected string
getTable(Model|string $table)
Get the table name from the given model or string.
in
InteractsWithDatabase at line 368
protected string|null
getTableConnection(Model|string|null $table)
Get the table connection specified in the given model.
in
InteractsWithDatabase at line 382
protected string|null
getDeletedAtColumn(Model|string $table, string|null $defaultColumnName = 'deleted_at')
Get the table column name used for soft deletes.
in
InteractsWithDatabase at line 392
protected Model|null
newModelFor(Model|string|null $table)
Get the model entity from the given model or string.
in
InteractsWithDatabase at line 403
InteractsWithDatabase
seed(array|string $class = 'Database\Seeders\DatabaseSeeder')
Seed a given database connection.
in
InteractsWithDeprecationHandling at line 21
protected InteractsWithDeprecationHandling
withDeprecationHandling()
Restore deprecation handling.
in
InteractsWithDeprecationHandling at line 37
protected InteractsWithDeprecationHandling
withoutDeprecationHandling()
Disable deprecation handling for the test.
in
InteractsWithEnvironment at line 15
protected void
setEnvironmentValue(string $key, string $value)
Set an environment variable for the current PHP process.
in
InteractsWithEnvironment at line 27
protected void
unsetEnvironmentValue(string $key)
Unset an environment variable for the current PHP process.
in
InteractsWithEnvironment at line 38
protected mixed
withEnvironmentValue(string $key, string|null $value, Closure $callback)
Run a callback with a temporary environment variable value.
in
InteractsWithEnvironment at line 48
protected mixed
withEnvironmentValues(array $values, Closure $callback)
Run a callback with temporary environment variable values.
in
ReflectsClosures at line 26
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
in
ReflectsClosures at line 49
protected array
firstClosureParameterTypes(Closure $closure)
Get the class names of the first parameter of the given Closure, including union types.
in
ReflectsClosures at line 75
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
in
ReflectsClosures at line 97
protected array
closureReturnTypes(Closure $closure)
Get the class names / types of the return type of the given Closure.
in
InteractsWithExceptionHandling at line 35
protected InteractsWithExceptionHandling
withExceptionHandling()
Restore exception handling.
in
InteractsWithExceptionHandling at line 54
protected InteractsWithExceptionHandling
handleExceptions(array $exceptions)
Only handle the given exceptions via the exception handler.
in
InteractsWithExceptionHandling at line 64
protected InteractsWithExceptionHandling
handleValidationExceptions()
Only handle validation exceptions via the exception handler.
in
InteractsWithExceptionHandling at line 75
protected InteractsWithExceptionHandling
withoutExceptionHandling(array $except = [])
Disable exception handling for the test.
in
InteractsWithExceptionHandling at line 91
__construct(ExceptionHandler $originalHandler, array $except = [])
Create a new exception handler instance.
in
InteractsWithExceptionHandling at line 103
void
report(Throwable $e, array $context = [], string|null $level = null)
Report or log an exception.
in
InteractsWithExceptionHandling at line 110
bool
shouldReport(Throwable $e)
Determine if the exception should be reported.
in
InteractsWithExceptionHandling at line 120
Response
render(Request $request, Throwable $e)
Render an exception into an HTTP response.
in
InteractsWithExceptionHandling at line 142
void
renderForConsole(OutputInterface $output, Throwable $e)
Render an exception to the console.
in
InteractsWithExceptionHandling at line 150
bool
isReporting(Throwable $e)
Determine if a given exception is being reported.
in
InteractsWithExceptionHandling at line 160
array
buildContextForException(Throwable $e)
Create the context for an exception.
in
InteractsWithExceptionHandling at line 169
void
afterResponse(callable $callback)
Register a callback to be called after an HTTP error response is rendered.
in
InteractsWithRouteMiddleware at line 15
protected void
assertRouteMiddlewareRunsBefore(string $routeName, string $before, string $after)
Assert route middleware runtime order.
in
InteractsWithRouteMiddleware at line 32
protected array
resolvedMiddlewareForRoute(string $routeName)
Get resolved runtime middleware for a named route.
in
InteractsWithSession at line 14
InteractsWithSession
withSession(array $data)
Set the session to the given array.
in
InteractsWithSession at line 26
InteractsWithSession
session(array $data)
Set the session to the given array.
in
InteractsWithSession at line 43
protected InteractsWithSession
startSession()
Start the session for the application.
in
InteractsWithSession at line 59
InteractsWithSession
flushSession()
Flush all of the current session data.
in
InteractsWithTime at line 24
mixed
freezeTime(callable|null $callback = null)
Freeze time.
in
InteractsWithTime at line 39
mixed
freezeSecond(callable|null $callback = null)
Freeze time at the beginning of the current second.
in
InteractsWithTime at line 49
Wormhole
travel(int $value)
Begin travelling to another time.
in
InteractsWithTime at line 64
mixed
travelTo(DateTimeInterface|Closure|string|bool|null $date, callable|null $callback = null)
Travel to another time.
in
InteractsWithTime at line 82
CarbonInterface
travelBack()
Travel back to the current time.
in
InteractsWithTestCaseLifecycle at line 72
protected void
setUpTheTestEnvironment()
| internal |
Set up the test environment.
in
InteractsWithTestCaseLifecycle at line 116
protected void
tearDownTheTestEnvironment()
| internal |
Clean up the testing environment before the next test.
in
InteractsWithTestCaseLifecycle at line 187
protected void
flushState()
Reset static state between test executions.
in
InteractsWithTestCaseLifecycle at line 196
protected array
setUpTraits()
Boot the testing helper traits.
at line 189
protected bool
setUpTheTestEnvironmentTraitToBeIgnored(string $use)
Skip Workbench's convention hook because it runs before database setup.
at line 147
protected void
setUpDatabaseTraits(array $uses)
Set up database-related testing traits.
Start Workbench before processing database attributes, so its migrations and seeders are registered before the database is migrated, refreshed or truncated.
in
InteractsWithTestCaseLifecycle at line 281
protected void
forgetStaleMigrationState(array $uses)
Forget retained migration state when a selected in-memory database is missing.
in
InteractsWithTestCaseLifecycle at line 301
static void
tearDownAfterClassUsingTestCase()
| internal |
Clean up the testing environment before the next test case.
in
InteractsWithTestCaseLifecycle 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.
in
InteractsWithTestCaseLifecycle at line 322
void
afterApplicationCreated(callable $callback)
Register a callback to be run after the application is created.
at line 320
void
beforeApplicationDestroyed(callable $callback)
Register a callback to be run before the application is destroyed.
Callbacks run newest first, so later setup is cleaned up before the setup it depends on.
in
InteractsWithTestCaseLifecycle at line 342
protected void
callBeforeApplicationDestroyedCallbacks()
Execute the application's pre-destruction callbacks.
in
InteractsWithTestCaseLifecycle 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.
in
InteractsWithTestCaseLifecycle 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).
in
InteractsWithViews at line 22
protected TestView
view(string $view, Arrayable|array $data = [])
Create a new TestView from the given view.
in
InteractsWithViews at line 33
protected TestView
blade(string $template, Arrayable|array $data = [])
Render the contents of the given Blade template string.
in
InteractsWithViews at line 78
protected TestComponent
component(string $componentClass, Arrayable|array $data = [])
Render the given view component.
in
InteractsWithViews at line 97
protected InteractsWithViews
withViewErrors(array $errors, string $key = 'default')
Populate the shared view error bag with the given errors.
in
MocksApplicationServices at line 32
$this
expectsEvents(array|string $events)
Specify a list of events that should be fired for the given operation.
These events will be mocked, so that handlers will not actually be executed.
in
MocksApplicationServices at line 58
$this
doesntExpectEvents(array|string $events)
Specify a list of events that should not be fired for the given operation.
These events will be mocked, so that handlers will not actually be executed.
in
MocksApplicationServices at line 79
protected $this
withoutEvents()
Mock the event dispatcher so all events are silenced and collected.
in
MocksApplicationServices at line 103
protected array
getFiredEvents(array $events)
Filter the given events against the fired events.
in
MocksApplicationServices at line 113
protected array
getDispatched(array $classes, array $dispatched)
Filter the given classes against an array of dispatched classes.
in
MocksApplicationServices at line 126
protected bool
wasDispatched(string $needle, array $haystack)
Check if the given class exists in an array of dispatched classes.
in
RunTestsInCoroutine at line 47
protected mixed
invokeTestMethod(string $methodName, array $testArguments)
Invoke the test method inside a Swoole coroutine container.
Uses PHPUnit 13's official extension point for customizing test method invocation. When coroutines are enabled and we're not already inside one, the test method runs inside Hypervel's coroutine container with full lifecycle management (context copying, setup/teardown hooks, cleanup).
in
RunTestsInCoroutine at line 132
protected void
enforceCoroutineTestTimeLimit(TimeoutException|null $timeoutException, bool $rootCompleted)
Enforce PHPUnit's deadline while the test or its children are suspended.
in
RunTestsInCoroutine at line 208
protected void
assertChildCoroutinesFinishedBeforeTimeLimit()
Fail a test whose expected exception was followed by child coroutines reaching the time limit.
in
RunTestsInCoroutine at line 223
protected bool
runsTestsInCoroutine()
Determine whether tests run in a coroutine.
in
RunTestsInCoroutine at line 231
protected bool
shouldBootFrameworkForTest()
Determine if framework lifecycle hooks should run for this test.
in
RunTestsInCoroutine at line 239
protected void
invokeSetupInCoroutine()
Run trait and test setup hooks in the test coroutine.
in
RunTestsInCoroutine at line 257
protected void
invokeTearDownInCoroutine(callable $capture)
Run test and trait teardown hooks while capturing failures.
in
RunTestsInCoroutine at line 280
protected void
clearNonCoroutineTransactionContext()
Clear transaction context from non-coroutine storage before test starts.
RefreshDatabase starts its wrapper transaction in setUp() (outside coroutine), storing it in nonCoroutineContext. We must preserve this data for copying into the coroutine. Only clear if there are no pending transactions (meaning any data is stale from a previous test that didn't clean up properly).
in
RunTestsInCoroutine at line 296
protected void
cleanupTestContext()
Clean up Context keys that cause test pollution.
Only forgets specific keys known to leak between tests. Does not use CoroutineContext::flush() because that would flush data needed by defer callbacks (e.g., Redis connections waiting to be released).
in
InteractsWithMockery at line 15
protected void
tearDownTheTestEnvironmentUsingMockery()
Tear down the testing environment using Mockery.
in
WithFaker at line 20
protected void
setUpFaker()
Set up the Faker instance.
in
WithFaker at line 28
protected Generator
faker(string|null $locale = null)
Get the default Faker instance for a given locale.
in
WithFaker at line 36
protected Generator
makeFaker(string|null $locale = null)
Create a Faker instance for the given locale.
at line 57
protected void
setUp()
Setup the test environment.
at line 217
protected void
refreshApplication()
Refresh the application instance.
in
CreatesApplication at line 245
Application
createApplication()
| internal |
Create the application instance.
Bootstraps the application manually step-by-step (like Orchestral Testbench's createApplication), rather than via kernel->bootstrap(), so defineEnvironment() can be called between RegisterProviders and BootProviders.
in
TestCase at line 114
protected void
prepareApplicationForCachedState(Application $app)
Prepare the application to reuse cached test state.
at line 243
protected void
tearDown()
Clean up the testing environment before the next test.
in
TestCase at line 166
protected bool
withoutBootingFramework()
Determine if the test method should run without booting the framework.
at line 338
static void
tearDownAfterClass()
Clean up the testing environment before the next test case.
in
InteractsWithParallelDatabase at line 43
protected void
configureParallelDatabaseName(mixed $app)
Rewrite the default connection's database name for parallel testing.
Config-only — does not create connections or purge pools. Called early in CreatesApplication (after config is loaded, before defineEnvironment) so that custom connections derived from the default connection inherit the per-worker database name.
No-op when not running in parallel or when using in-memory SQLite.
in
InteractsWithParallelDatabase at line 97
protected void
ensureParallelDatabaseExists()
Ensure the per-worker database exists, creating it if needed.
Called before Testbench database requirements and from database testing traits (RefreshDatabase, DatabaseMigrations, DatabaseTruncation, DatabaseTransactions) after the app is booted and connections are available. The config has already been rewritten by configureParallelDatabaseName().
No-op when not running in parallel or when using in-memory SQLite.
in
InteractsWithParallelDatabase at line 160
protected bool
shouldManageParallelDatabase(mixed $driver, string $database)
Determine if the database should be managed for parallel testing.
in
InteractsWithParallelDatabase at line 187
protected string
parallelTestDatabase(string $database, string $token)
Get the per-worker test database name.
in
InteractsWithTestCase at line 54
static bool
usesTestingConcern(string|null $trait = null)
Determine if the test case uses the given trait, or the Testing trait by default.
in
InteractsWithTestCase at line 62
static bool
usesRefreshDatabaseTestingConcern()
Determine if the test case uses refresh-database testing concerns.
in
InteractsWithTestCase at line 75
static array
cachedUsesForTestCase()
| internal |
Cache and return traits used by test case.
in
InteractsWithTestCase at line 89
static void
usesTestingFeature(object $attribute, int $flag = Attribute::TARGET_CLASS)
Programmatically add a testing feature attribute.
in
InteractsWithTestCase at line 120
abstract static protected Collection
resolvePhpUnitAttributesForMethod(string $className, string|null $methodName = null)
Resolve PHPUnit method attributes for specific method.
in
InteractsWithTestCase at line 127
protected void
setUpTheTestEnvironmentUsingTestCase()
| internal |
Execute BeforeEach lifecycle attributes.
in
InteractsWithTestCase at line 142
protected void
tearDownTheTestEnvironmentUsingTestCase()
| internal |
Execute AfterEach lifecycle attributes.
in
InteractsWithTestCase at line 178
static void
setUpBeforeClassUsingTestCase()
| internal |
Load test fixtures and execute BeforeAll lifecycle attributes.
in
InteractsWithPHPUnit at line 56
bool
isRunningTestCase()
Determine if the object is running as a PHPUnit test case.
in
InteractsWithPHPUnit at line 68
string|null
resolvePhpUnitTestClassName()
| internal |
Resolve the PHPUnit test class name.
in
InteractsWithPHPUnit at line 84
string|null
resolvePhpUnitTestMethodName()
| internal |
Resolve the PHPUnit test method name.
in
InteractsWithPHPUnit at line 100
protected Collection
resolvePhpUnitAttributes()
| internal |
Resolve and cache PHPUnit attributes for current test.
in
InteractsWithPHPUnit at line 146
void
setUpTheEnvironmentUsing(Closure $setUp)
| internal |
Define the setUp environment using callback.
in
InteractsWithPHPUnit at line 158
void
tearDownTheEnvironmentUsing(Closure $tearDown)
| internal |
Define the tearDown environment using callback.
in
InteractsWithPHPUnit at line 168
static void
setUpBeforeClassUsingPHPUnit()
| internal |
Cache uses for test case before class runs.
in
InteractsWithPHPUnit at line 178
static void
tearDownAfterClassUsingPHPUnit()
| internal |
Clear PHPUnit caches after class teardown.
in
InteractsWithPest at line 19
bool
isRunningTestCaseUsingPest()
Determine if the trait is used within testing using Pest.
in
InteractsWithPest at line 27
static protected bool
isRunningViaPestPrinter(object|string $object)
Determine if the object implements Pest test runner.
in
InteractsWithWorkbench at line 29
static string|null
applicationBasePathUsingWorkbench()
| internal |
Get Application's base path.
in
InteractsWithWorkbench at line 41
array|null
ignorePackageDiscoveriesFromUsingWorkbench()
| internal |
Ignore package discovery from.
in
InteractsWithWorkbench at line 59
protected array|null
getPackageBootstrappersUsingWorkbench(Application $app)
| internal |
Get package bootstrapper.
in
InteractsWithWorkbench at line 77
protected array|null
getPackageProvidersUsingWorkbench(Application $app)
| internal |
Get package providers.
in
InteractsWithWorkbench at line 104
protected string
applicationConsoleKernelUsingWorkbench(Application $app)
| internal |
Resolve application Console Kernel implementation.
in
InteractsWithWorkbench at line 118
protected string
applicationHttpKernelUsingWorkbench(Application $app)
| internal |
Get application HTTP Kernel implementation using Workbench.
in
InteractsWithWorkbench at line 132
protected string
applicationExceptionHandlerUsingWorkbench(Application $app)
| internal |
Get application HTTP exception handler using Workbench.
in
InteractsWithWorkbench at line 144
static Config|null
cachedConfigurationForWorkbench()
Get the cached Workbench configuration.
in
WithHypervelBootstrapFile at line 29
protected string|false
getApplicationBootstrapFile(string $filename)
| internal |
Get application bootstrap file path (if exists).
in
WithHypervelBootstrapFile at line 49
protected bool
hasCustomApplicationKernels()
| internal |
Determine if application is using a custom application kernels.
in
WithHypervelBootstrapFile at line 58
protected bool
usesTestbenchDefaultSkeleton()
Determine if application is bootstrapped using Testbench's default skeleton.
in
WithHypervelBootstrapFile at line 70
abstract protected string
getApplicationBasePath()
Get the application's base path.
in
CreatesApplication at line 83
static string
applicationBasePath()
Get the base path for the application.
in
CreatesApplication at line 95
array
ignorePackageDiscoveriesFrom()
Ignore package discovery from.
in
CreatesApplication at line 117
protected array
getPackageProviders(Application $app)
Get package providers.
in
CreatesApplication at line 129
protected array
getPackageBootstrappers(Application $app)
Get package bootstrappers.
in
CreatesApplication at line 144
protected array
getApplicationProviders(Application $app)
Get application providers.
Override in test classes to filter the default provider list before registration. For example, to remove SessionServiceProvider.
in
CreatesApplication at line 154
protected string|null
getApplicationTimezone(Application $app)
Get the application timezone.
in
CreatesApplication at line 169
protected array
overrideApplicationProviders(Application $app)
Override application providers.
Return a map of provider class names to replacements. Set a provider
to false to remove it entirely, or to another class name to replace it.
in
CreatesApplication at line 181
protected array
getApplicationAliases(Application $app)
Get application aliases.
in
CreatesApplication at line 193
protected array
overrideApplicationAliases(Application $app)
Override application aliases.
in
CreatesApplication at line 205
protected array
getPackageAliases(Application $app)
Get package aliases.
in
CreatesApplication at line 217
protected array
overrideApplicationBindings(Application $app)
Override application bindings.
in
CreatesApplication at line 230
protected void
defineEnvironment(Application $app)
Define environment setup.
Override in subclasses to modify config before providers boot. This is where test classes set database drivers, cache stores, etc.
in
CreatesApplication at line 304
protected Application
resolveDefaultApplication()
| internal |
Create the default application implementation.
in
CreatesApplication at line 319
protected Application
resolveApplication()
Resolve the application instance.
in
CreatesApplication at line 339
protected void
resolveApplicationResolvingCallback(Application $app)
Resolve application resolving callback.
in
CreatesApplication at line 354
protected void
resolveApplicationFacades(Application $app)
Resolve application facades implementation.
in
CreatesApplication at line 365
protected void
resolveApplicationBindings(Application $app)
| internal |
Resolve application bindings.
in
CreatesApplication at line 377
protected void
resolveApplicationExceptionHandler(Application $app)
Resolve application HTTP exception handler.
in
CreatesApplication at line 387
protected void
resolveApplicationCore(Application $app)
| internal |
Resolve application core environment.
in
CreatesApplication at line 399
protected void
resolveApplicationEnvironmentVariables(Application $app)
| internal |
Resolve application environment variables.
in
CreatesApplication at line 441
protected void
resolveApplicationComposerVendorDirectory()
| internal |
Make a relative COMPOSER_VENDOR_DIR from the application environment absolute.
Child processes such as the skeleton's artisan resolve a relative value against their own base path rather than the package root. Bootstrapper already exported an inherited value; rewriting a loaded one through the repository keeps its putenv setting and restoration.
in
CreatesApplication at line 465
protected Closure
maskInheritedApplicationEnvironment()
Mask inherited framework APP_ENV for Testbench applications that opt out of loading env files.
The framework suite forces APP_ENV=testing globally via phpunit.xml.dist. Tests that disable environment loading should instead use the configuration defaults unless they explicitly provided APP_ENV or package-tester mode is enabled.
in
CreatesApplication at line 503
protected bool
hasConfiguredApplicationEnvironmentVariable(string $key)
Determine if the current test explicitly configured an environment variable.
in
CreatesApplication at line 517
protected void
resolveApplicationHttpKernel(Application $app)
Resolve application HTTP kernel implementation.
in
CreatesApplication at line 527
protected void
resolveApplicationHttpMiddlewares(Application $app)
| internal |
Resolve application HTTP default middlewares.
in
CreatesApplication at line 564
protected void
resolveApplicationConsoleKernel(Application $app)
Resolve application console kernel implementation.
in
CreatesApplication at line 580
protected void
resolveApplicationConfiguration(Application $app)
| internal |
Load configuration and register package providers/aliases.
Equivalent to Orchestral's resolveApplicationConfiguration(): loads config files, then sets app.providers and app.aliases in config BEFORE RegisterProviders reads them.
in
CreatesApplication at line 634
protected array
resolveApplicationAliases(Application $app)
| internal |
Resolve application aliases.
in
CreatesApplication at line 657
protected string|false
resolveApplicationRouteProvider(array $overrides)
Resolve the route provider from application provider overrides.
in
CreatesApplication at line 672
protected array
resolveApplicationProviders(Application $app)
| internal |
Resolve the final application provider list.
Merges package providers, then applies overrides (replacements/removals) to produce the list RegisterProviders uses.
in
CreatesApplication at line 704
protected void
resolveApplicationBootstrappers(Application $app)
| internal |
Run bootstrappers individually with defineEnvironment() inserted.
Equivalent to Orchestral's resolveApplicationBootstrappers().
in
CreatesApplication at line 764
protected void
refreshApplicationRouteNameLookups(Application $app)
| internal |
Refresh route name lookups now and whenever the URL generator is resolved.
Route names set via fluent ->name() after RouteCollection::add() are not indexed until refreshNameLookups() rebuilds the lookup table. This method ensures names are refreshed both immediately and lazily — the after_resolving callback catches routes defined inside test methods (after boot) by firing whenever app('url') is resolved.
in
CreatesApplication at line 781
protected void
resolveApplicationRateLimiting(Application $app)
Resolve application rate limiting configuration.
in
CreatesApplication at line 802
protected void
configureParallelCachePaths()
Configure worker-specific cache paths for parallel testing.
When running under ParaTest, each worker gets a unique route cache path to prevent filesystem races. Without this, one worker's defineCacheRoutes() writes a shared cache file that causes other workers' routesAreCached() to return true, skipping route setup.
in
CreatesApplication at line 820
protected string|null
paraTestWorkerToken()
Get the current ParaTest worker token before the application exists.
This reads the raw runtime arrays because cached route setup may run before parent::setUp(), when no application or ParallelTesting service has been created yet.
in
CreatesApplication at line 828
static protected Throwable|null
terminateAndFlushApplication(Application $app)
Terminate and flush an application, returning any cleanup failure.
in
HandlesAssertions at line 17
protected void
markTestSkippedUnless(bool|Closure $condition, string $message)
Mark the test as skipped when condition is not equivalent to true.
in
HandlesAssertions at line 27
protected void
markTestSkippedWhen(bool|Closure $condition, string $message)
Mark the test as skipped when condition is equivalent to true.
in
HandlesAttributes at line 31
protected FeaturesCollection
parseTestMethodAttributes(Application $app, string $attribute)
| internal |
Parse and execute test method attributes of a specific type.
Note: Attributes are already executed automatically via setUpTheTestEnvironmentUsingTestCase(). This method is for internal use by the testing infrastructure.
in
HandlesDatabases at line 30
protected void
setUpDatabaseRequirements(Closure $callback)
| internal |
Setup database requirements.
in
HandlesDatabases at line 76
protected bool
usesSqliteInMemoryDatabaseConnection(string|null $connection = null)
Determine if using in-memory SQLite database connection.
in
HandlesDatabases at line 96
protected void
defineDatabaseMigrations()
Define database migrations.
in
HandlesDatabases at line 106
protected void
defineDatabaseMigrationsAfterDatabaseRefreshed()
Define database migrations after database refreshed.
in
HandlesDatabases at line 116
protected void
destroyDatabaseMigrations()
Destroy database migrations.
in
HandlesDatabases at line 126
protected void
defineDatabaseSeeders()
Define database seeders.
in
HandlesRoutes at line 60
protected void
setUpApplicationRoutes(Application $app)
| internal |
Setup application routes.
in
HandlesRoutes at line 87
protected void
defineRoutes(Router $router)
Define routes setup.
in
HandlesRoutes at line 97
protected void
defineWebRoutes(Router $router)
Define web routes setup.
in
HandlesRoutes at line 107
protected void
defineStashRoutes(Closure|string $route)
Define stash routes setup.
in
HandlesRoutes at line 117
protected void
defineCacheRoutes(Closure|string $route, bool $cached = true)
Define cache routes setup.
in
HandlesRoutes at line 194
protected void
syncTestbenchRoutes()
| internal |
Synchronize Testbench routes.
in
HandlesRoutes at line 213
protected void
registerTestbenchRouteCleanup(Filesystem $files, string $cachedRoutesPath)
Register cleanup for route files and route cache written by this test.
in
HandlesRoutes at line 266
protected string
testbenchRouteFilePath(string $basePath)
Get a route file path owned by this test instance.
in
InteractsWithMigrations at line 39
protected void
setUpInteractsWithMigrations()
Setup the test environment.
in
InteractsWithMigrations at line 51
protected void
tearDownInteractsWithMigrations()
Teardown the test environment.
in
InteractsWithMigrations at line 95
protected void
loadMigrationsFrom(array|string $paths)
Define hooks to migrate the database before and after each test.
in
InteractsWithMigrations at line 116
protected bool
shouldRegisterMigrationPaths()
Determine whether migration paths should be registered for an upcoming migration.
in
InteractsWithMigrations at line 152
protected array
resolvePackageMigrationsOptions(array|string $paths = [])
| internal |
Resolve Package Migrations Artisan command options.
in
InteractsWithMigrations at line 172
protected void
loadHypervelMigrations(array|string $database = [])
Migrate Hypervel's default migrations.
in
InteractsWithMigrations at line 191
protected void
runHypervelMigrations(array|string $database = [])
Migrate all Hypervel migrations.
in
InteractsWithMigrations at line 207
protected array
resolveHypervelMigrationsOptions(array|string $database = [])
| internal |
Resolve Hypervel Migrations Artisan command options.
in
InteractsWithMigrations at line 217
protected void
runMigrationProcessor(Application $app, array $options)
Run and retain a migration processor for teardown.
in
InteractsWithMigrations at line 245
protected bool
usesInMemoryDatabaseForMigrationState()
Determine whether the active database concerns retain in-memory state.
in
InteractsWithMigrations at line 267
protected void
resetApplicationArtisanCommands(Application $app)
| internal |
Reset artisan commands for the application.
in
Testing at line 32
protected void
reloadApplication()
Reload the application instance.
at line 69
protected void
setUpTheTestbenchEnvironment()
| internal |
Set up the Testbench environment.
Application reloads call this directly, so the test case's own setUp() runs only once.
at line 115
protected void
preservePackageManifestCache()
Preserve the package manifest cache for the duration of the test.
at line 197
protected void
prepareDatabaseTruncationForMethod(array $uses)
Isolate method-specific migration sets from the retained truncation schema.
at line 255
protected void
tearDownTheTestbenchEnvironment()
| internal |
Clean up the Testbench environment.
Application reloads call this directly, so the test case's own tearDown() runs only once.
at line 328
static void
setUpBeforeClass()
Prepare the testing environment before the running the test case.
at line 40
void
refreshDatabase()
No description
at line 40
void
runDatabaseMigrations()
No description
at line 40
void
truncateDatabaseTables()
No description
at line 40
void
beginDatabaseTransaction()
No description
at line 40
void
disableMiddlewareForAllTests()
No description
at line 40
void
disableEventsForAllTests()
No description