TestCase
abstract class TestCase extends TestCase
Traits
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 | $expectedTables | All of the expected output tables. |
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 | $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 array | $firedEvents | All of the fired events. |
from MocksApplicationServices |
| protected bool | $runTestsInCoroutine | from RunTestsInCoroutine | |
| protected bool | $copyNonCoroutineContext | from RunTestsInCoroutine | |
| protected Generator|null | $faker | The Faker instance. |
from WithFaker |
| protected bool|null | $withoutBootingFramework | Memoized result of the withoutBootingFramework check. |
Methods
Register an instance of an object in the container.
Register an instance of an object 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.
No description
No description
No description
No description
No description
No description
No description
No description
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.
Alias of command method.
Call Hypervel command and return 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 connection specified in the given model.
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.
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.
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.
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.
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.
Determine if the test method should boot the framework.
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.
Set up the test environment.
Refresh the application instance.
Create the application.
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.
Details
in
InteractsWithContainer at line 33
protected mixed
swap(string $abstract, mixed $instance)
Register an instance of an object in the container.
in
InteractsWithContainer at line 44
protected mixed
instance(string $abstract, mixed $instance)
Register an instance of an object in the container.
in
InteractsWithContainer at line 55
protected MockInterface
mock(string $abstract, Closure|null $mock = null)
Mock an instance of an object in the container.
in
InteractsWithContainer at line 63
protected MockInterface
partialMock(string $abstract, Closure|null $mock = null)
Mock a partial instance of an object in the container.
in
InteractsWithContainer at line 71
protected MockInterface
spy(string $abstract, Closure|null $mock = null)
Spy an instance of an object in the container.
in
InteractsWithContainer at line 81
protected InteractsWithContainer
forgetMock(string $abstract)
Instruct the container to forget a previously mocked / spied instance of an object.
in
InteractsWithContainer at line 93
protected InteractsWithContainer
withoutVite()
Register a Vite handler that returns empty strings for all assets.
in
InteractsWithContainer at line 102
HtmlString
__invoke(string|array $entrypoints, string|null $buildDirectory = null)
No description
in
InteractsWithContainer at line 107
mixed
__call(string $method, array $parameters)
No description
in
InteractsWithContainer at line 112
string
__toString()
No description
in
InteractsWithContainer at line 117
InteractsWithContainer
useIntegrityKey(string|false $key)
No description
in
InteractsWithContainer at line 122
InteractsWithContainer
useBuildDirectory(string $path)
No description
in
InteractsWithContainer at line 127
InteractsWithContainer
useHotFile(string $path)
No description
in
InteractsWithContainer at line 132
InteractsWithContainer
withEntryPoints(array $entryPoints)
No description
in
InteractsWithContainer at line 137
InteractsWithContainer
useScriptTagAttributes(array|callable $attributes)
No description
in
InteractsWithContainer at line 142
InteractsWithContainer
useStyleTagAttributes(array|callable $attributes)
No description
in
InteractsWithContainer at line 147
InteractsWithContainer
usePreloadTagAttributes(array|callable|false $attributes)
No description
in
InteractsWithContainer at line 152
array
preloadedAssets()
No description
in
InteractsWithContainer at line 157
HtmlString
reactRefresh()
No description
in
InteractsWithContainer at line 162
string
content(string $asset, string|null $buildDirectory = null)
No description
in
InteractsWithContainer at line 167
string
asset(string $asset, string|null $buildDirectory = null)
No description
in
MakesHttpRequests at line 73
MakesHttpRequests
withHeaders(array $headers)
Define additional headers to be sent with the request.
in
MakesHttpRequests at line 83
MakesHttpRequests
withHeader(string $name, string $value)
Add a header to be sent with the request.
in
MakesHttpRequests at line 93
MakesHttpRequests
withoutHeader(string $name)
Remove a header from the request.
in
MakesHttpRequests at line 103
MakesHttpRequests
withoutHeaders(array $headers)
Remove headers from the request.
in
MakesHttpRequests at line 115
MakesHttpRequests
withToken(string $token, string $type = 'Bearer')
Add an authorization token for the request.
in
MakesHttpRequests at line 123
MakesHttpRequests
withBasicAuth(string $username, string $password)
Add a basic authentication header to the request with the given credentials.
in
MakesHttpRequests at line 131
MakesHttpRequests
withoutToken()
Remove the authorization token from the request.
in
MakesHttpRequests at line 139
MakesHttpRequests
flushHeaders()
Flush all the configured headers.
in
MakesHttpRequests at line 149
MakesHttpRequests
withServerVariables(array $server)
Define a set of server variables to be sent with the requests.
in
MakesHttpRequests at line 161
MakesHttpRequests
withoutMiddleware(null|array|string $middleware = null)
Disable middleware for the test.
in
MakesHttpRequests at line 181
MakesHttpRequests
withMiddleware(null|array|string $middleware = null)
Enable the given middleware for the test.
in
MakesHttpRequests at line 199
MakesHttpRequests
withCookies(array $cookies)
Define additional cookies to be sent with the request.
in
MakesHttpRequests at line 209
MakesHttpRequests
withCookie(string $name, string $value)
Add a cookie to be sent with the request.
in
MakesHttpRequests at line 219
MakesHttpRequests
withUnencryptedCookies(array $cookies)
Define additional cookies that will not be encrypted before sending with the request.
in
MakesHttpRequests at line 229
MakesHttpRequests
withUnencryptedCookie(string $name, string $value)
Add a cookie that will not be encrypted before sending with the request.
in
MakesHttpRequests at line 239
MakesHttpRequests
followingRedirects()
Automatically follow any redirects returned from the response.
in
MakesHttpRequests at line 249
MakesHttpRequests
withCredentials()
Include cookies and authorization headers for JSON requests.
in
MakesHttpRequests at line 259
MakesHttpRequests
disableCookieEncryption()
Disable automatic encryption of cookie values.
in
MakesHttpRequests at line 269
MakesHttpRequests
from(string $url)
Set the referer header and previous URL session value in order to simulate a previous request.
in
MakesHttpRequests at line 279
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 287
MakesHttpRequests
withPrecognition()
Set the Precognition header to "true".
in
MakesHttpRequests at line 295
TestResponse
get(Stringable|string $uri, array $headers = [])
Visit the given URI with a GET request.
in
MakesHttpRequests at line 306
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 314
TestResponse
post(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a POST request.
in
MakesHttpRequests at line 325
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 333
TestResponse
put(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a PUT request.
in
MakesHttpRequests at line 344
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 352
TestResponse
patch(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a PATCH request.
in
MakesHttpRequests at line 363
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 371
TestResponse
delete(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a DELETE request.
in
MakesHttpRequests at line 382
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 390
TestResponse
options(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with an OPTIONS request.
in
MakesHttpRequests at line 401
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 409
TestResponse
head(Stringable|string $uri, array $headers = [])
Visit the given URI with a HEAD request.
in
MakesHttpRequests at line 420
TestResponse
query(Stringable|string $uri, array $data = [], array $headers = [])
Visit the given URI with a QUERY request.
in
MakesHttpRequests at line 431
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 443
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 474
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 546
protected string
prepareUrlForRequest(Stringable|string $uri)
Turn the given URI into a fully-qualified URL.
in
MakesHttpRequests at line 560
protected void
syncRequestContextToParent(Request $request)
Sync durable request Context state to the test coroutine.
in
MakesHttpRequests at line 577
protected array
sessionContextSnapshot(Request $request)
Get a snapshot of durable session Context state for the completed request.
in
MakesHttpRequests at line 600
protected array
sessionContextKeys()
Get durable session Context keys.
in
MakesHttpRequests at line 619
protected array
sessionStoreContextKeys(Store $session)
Get the Context keys for the given session store.
in
MakesHttpRequests at line 635
protected array
authenticationContextKeys()
Get durable authentication Context keys.
in
MakesHttpRequests at line 653
protected array
transformHeadersToServerVars(array $headers)
Transform headers array to array of $SERVER vars with HTTP* format.
in
MakesHttpRequests at line 665
protected string
formatServerHeaderKey(string $name)
Format the header name for the server array.
in
MakesHttpRequests at line 677
protected array
extractFilesFromDataArray(array $data)
Extract the file uploads from the given data array.
in
MakesHttpRequests at line 701
protected array
prepareCookiesForRequest()
If enabled, encrypt cookie values for request.
in
MakesHttpRequests at line 716
protected array
prepareCookiesForJsonRequest()
Prepare cookies for JSON requests.
in
MakesHttpRequests at line 725
protected TestResponse
followRedirects(mixed $response)
Follow a redirect chain until a non-redirect is received.
in
MakesHttpRequests at line 739
protected Request
createTestRequest(Request $symfonyRequest)
Create the request instance used for testing from the given Symfony request.
in
MakesHttpRequests at line 748
protected TestResponse
createTestResponse(mixed $response, Request|null $request = null)
Create the test response instance from the given response.
in
MakesHttpRequests at line 765
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 790
protected Waiter
getWaiter()
Get the coroutine waiter for test requests.
in
InteractsWithAuthentication at line 14
InteractsWithAuthentication
actingAs(Authenticatable $user, string|null $guard = null)
Set the currently logged in user for the application.
in
InteractsWithAuthentication at line 22
InteractsWithAuthentication
actingAsGuest(string|null $guard = null)
Clear the currently logged in user for the application.
in
InteractsWithAuthentication at line 34
InteractsWithAuthentication
be(Authenticatable $user, string|null $guard = null)
Set the currently logged in user for the application.
in
InteractsWithAuthentication at line 50
InteractsWithAuthentication
assertAuthenticated(string|null $guard = null)
Assert that the user is authenticated.
in
InteractsWithAuthentication at line 60
InteractsWithAuthentication
assertGuest(string|null $guard = null)
Assert that the user is not authenticated.
in
InteractsWithAuthentication at line 70
protected bool
isAuthenticated(string|null $guard = null)
Return true if the user is authenticated, false otherwise.
in
InteractsWithAuthentication at line 78
InteractsWithAuthentication
assertAuthenticatedAs(Authenticatable $user, string|null $guard = null)
Assert that the user is authenticated as the given user.
in
InteractsWithAuthentication at line 102
InteractsWithAuthentication
assertCredentials(array $credentials, string|null $guard = null)
Assert that the given credentials are valid.
in
InteractsWithAuthentication at line 115
InteractsWithAuthentication
assertInvalidCredentials(array $credentials, string|null $guard = null)
Assert that the given credentials are invalid.
in
InteractsWithAuthentication at line 128
protected bool
hasCredentials(array $credentials, string|null $guard = null)
Return true if the credentials are valid, false otherwise.
in
InteractsWithConsole at line 60
int|PendingCommand
artisan(string $command, array $parameters = [])
Alias of command method.
in
InteractsWithConsole at line 68
int|PendingCommand
command(string $command, array $parameters = [])
Call Hypervel command and return code.
in
InteractsWithConsole at line 85
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 29
protected $this
assertDatabaseHas(Model>|Model|Model>|string $table, array $data = [], null|string $connection = null)
Assert that a given where condition exists in the database.
in
InteractsWithDatabase at line 70
protected $this
assertDatabaseMissing(Model>|Model|Model>|string $table, array $data = [], null|string $connection = null)
Assert that a given where condition does not exist in the database.
in
InteractsWithDatabase at line 111
protected $this
assertDatabaseCount(Model|string $table, int $count, null|string $connection = null)
Assert the count of table entries.
in
InteractsWithDatabase at line 128
protected $this
assertDatabaseEmpty(Model>|Model|Model>|Model|string>|string $table, null|string $connection = null)
Assert that the given table or tables has no entries.
in
InteractsWithDatabase at line 155
protected $this
assertSoftDeleted(Model>|Model|Model>|Model|string>|string $table, array $data = [], null|string $connection = null, null|string $deletedAtColumn = 'deleted_at')
Assert the given record has been "soft deleted".
in
InteractsWithDatabase at line 203
protected $this
assertNotSoftDeleted(Model>|Model|Model>|Model|string>|string $table, array $data = [], null|string $connection = null, null|string $deletedAtColumn = 'deleted_at')
Assert the given record has not been "soft deleted".
in
InteractsWithDatabase at line 248
protected $this
assertModelExists(Model>|Model|Model>|string $model)
Assert the given model exists in the database.
in
InteractsWithDatabase at line 259
protected $this
assertModelMissing(Model>|Model|Model>|string $model)
Assert the given model does not exist in the database.
in
InteractsWithDatabase at line 271
$this
expectsDatabaseQueryCount(int $expected, null|string $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 314
Expression
castAsJson(array|object|string $value, null|string $connection = null)
Cast a JSON string to a database compatible type.
in
InteractsWithDatabase at line 338
protected Connection
getConnection(null|string $connection = null, null|Model>|Model|string $table = null)
Get the database connection.
in
InteractsWithDatabase at line 359
protected string
getTable(Model>|Model|string $table)
Get the table name from the given model or string.
in
InteractsWithDatabase at line 374
protected null|string
getTableConnection(Model>|Model|string $table)
Get the table connection specified in the given model.
in
InteractsWithDatabase at line 390
protected string
getDeletedAtColumn(string $table, string $defaultColumnName = 'deleted_at')
Get the table column name used for soft deletes.
in
InteractsWithDatabase at line 401
protected null|Model
newModelFor(Model|string $table)
Get the model entity from the given model or string.
in
InteractsWithDatabase at line 411
InteractsWithDatabase
seed(array|string $class = 'Database\Seeders\DatabaseSeeder')
Seed a given database connection.
in
InteractsWithDeprecationHandling at line 19
protected InteractsWithDeprecationHandling
withDeprecationHandling()
Restore deprecation handling.
in
InteractsWithDeprecationHandling at line 33
protected InteractsWithDeprecationHandling
withoutDeprecationHandling()
Disable deprecation handling for the test.
in
InteractsWithEnvironment at line 14
protected void
setEnvironmentValue(string $key, string $value)
Set an environment variable for the current PHP process.
in
InteractsWithEnvironment at line 26
protected void
unsetEnvironmentValue(string $key)
Unset an environment variable for the current PHP process.
in
ReflectsClosures at line 25
protected string
firstClosureParameterType(Closure $closure)
Get the class name of the first parameter of the given Closure.
in
ReflectsClosures at line 48
protected array
firstClosureParameterTypes(Closure $closure)
Get the class names of the first parameter of the given Closure, including union types.
in
ReflectsClosures at line 74
protected array
closureParameterTypes(Closure $closure)
Get the class names / types of the parameters of the given Closure.
in
ReflectsClosures at line 94
protected array
closureReturnTypes(Closure $closure)
Get the class names / types of the return type of the given Closure.
in
InteractsWithExceptionHandling at line 32
protected InteractsWithExceptionHandling
withExceptionHandling()
Restore exception handling.
in
InteractsWithExceptionHandling at line 50
protected InteractsWithExceptionHandling
handleExceptions(array $exceptions)
Only handle the given exceptions via the exception handler.
in
InteractsWithExceptionHandling at line 58
protected InteractsWithExceptionHandling
handleValidationExceptions()
Only handle validation exceptions via the exception handler.
in
InteractsWithExceptionHandling at line 68
protected InteractsWithExceptionHandling
withoutExceptionHandling(array $except = [])
Disable exception handling for the test.
in
InteractsWithExceptionHandling at line 82
__construct(ExceptionHandler $originalHandler, array $except = [])
No description
in
InteractsWithExceptionHandling at line 91
void
report(Throwable $e)
Report or log an exception.
in
InteractsWithExceptionHandling at line 98
bool
shouldReport(Throwable $e)
Determine if the exception should be reported.
in
InteractsWithExceptionHandling at line 108
Response
render(Request $request, Throwable $e)
Render an exception into an HTTP response.
in
InteractsWithExceptionHandling at line 130
void
renderForConsole(OutputInterface $output, Throwable $e)
Render an exception to the console.
in
InteractsWithExceptionHandling at line 138
void
afterResponse(callable $callback)
Register a callback to be called after an HTTP error response is rendered.
in
InteractsWithRouteMiddleware at line 16
protected void
assertRouteMiddlewareRunsBefore(string $routeName, string $before, string $after)
Assert route middleware runtime order.
in
InteractsWithRouteMiddleware at line 33
protected array
resolvedMiddlewareForRoute(string $routeName)
Get resolved runtime middleware for a named route.
in
InteractsWithSession at line 12
InteractsWithSession
withSession(array $data)
Set the session to the given array.
in
InteractsWithSession at line 22
InteractsWithSession
session(array $data)
Set the session to the given array.
in
InteractsWithSession at line 36
protected InteractsWithSession
startSession()
Start the session for the application.
in
InteractsWithSession at line 48
InteractsWithSession
flushSession()
Flush all of the current session data.
in
InteractsWithTime at line 22
mixed
freezeTime(null|callable $callback = null)
Freeze time.
in
InteractsWithTime at line 35
mixed
freezeSecond(null|callable $callback = null)
Freeze time at the beginning of the current second.
in
InteractsWithTime at line 45
Wormhole
travel(int $value)
Begin travelling to another time.
in
InteractsWithTime at line 57
mixed
travelTo(null|bool|CarbonInterface|Closure|DateTimeInterface|string $date, null|callable $callback = null)
Travel to another time.
in
InteractsWithTime at line 73
CarbonInterface
travelBack()
Travel back to the current time.
in
InteractsWithTestCaseLifecycle at line 62
protected void
setUpTheTestEnvironment()
| internal |
Set up the test environment.
in
InteractsWithTestCaseLifecycle at line 101
protected void
tearDownTheTestEnvironment()
| internal |
Clean up the testing environment before the next test.
in
InteractsWithTestCaseLifecycle at line 180
protected array
setUpTraits()
Boot the testing helper traits.
in
InteractsWithTestCaseLifecycle 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.
in
InteractsWithTestCaseLifecycle at line 251
static void
tearDownAfterClassUsingTestCase()
| internal |
Clean up the testing environment before the next test case.
in
InteractsWithTestCaseLifecycle at line 264
afterApplicationCreated(callable $callback)
Register a callback to be run after the application is created.
in
InteractsWithTestCaseLifecycle at line 276
protected
beforeApplicationDestroyed(callable $callback)
Register a callback to be run before the application is destroyed.
in
InteractsWithTestCaseLifecycle at line 284
protected
callBeforeApplicationDestroyedCallbacks()
Execute the application's pre-destruction callbacks.
in
InteractsWithTestCaseLifecycle 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().
in
InteractsWithTestCaseLifecycle 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).
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 34
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 91
protected bool
runsTestsInCoroutine()
Determine whether tests run in a coroutine.
at line 118
protected bool
shouldBootFrameworkForTest()
Determine if the test method should boot the framework.
in
RunTestsInCoroutine at line 104
protected void
invokeSetupInCoroutine()
No description
in
RunTestsInCoroutine at line 119
protected void
invokeTearDownInCoroutine(callable $capture)
No description
in
RunTestsInCoroutine at line 142
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 158
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 58
protected void
setUp()
Set up the test environment.
at line 70
protected void
refreshApplication()
Refresh the application instance.
at line 78
protected Application
createApplication()
Create the application.
at line 92
protected void
tearDown()
Clean up the testing environment before the next test.
at line 126
protected bool
withoutBootingFramework()
Determine if the test method should run without booting the framework.
at line 142
static void
tearDownAfterClass()
Clean up the testing environment before the next test case.