class TestCase extends TestCase implements TestCase

internal  
 

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

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.

from  TestCase
static protected string|null $originalDatabaseName

The original database name before parallel suffixing.

from  InteractsWithParallelDatabase
static protected string|bool|null $cacheApplicationBootstrapFile

Cached application bootstrap file path.

from  InteractsWithTestCase
static protected null|array<class-string, class-string> $cachedTestCaseUses

Cached traits used by test case.

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 bool $requireApplicationCachedRoutesHasRun

Whether cached routes have been loaded 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 from  InteractsWithMigrations
protected string $baseUrl

The base URL to use while testing the application.

protected bool $loadEnvironmentVariables

Automatically loads environment variables when available.

static protected bool $hasBootstrappedTestbench

Methods

mixed
swap(string $abstract, mixed $instance)

Register an instance of an object in the container.

mixed
instance(string $abstract, mixed $instance)

Register an instance of an object in the container.

MockInterface
mock(string $abstract, Closure|null $mock = null)

Mock an instance of an object in the container.

MockInterface
partialMock(string $abstract, Closure|null $mock = null)

Mock a partial instance of an object in the container.

MockInterface
spy(string $abstract, Closure|null $mock = null)

Spy an instance of an object in the container.

forgetMock(string $abstract)

Instruct the container to forget a previously mocked / spied instance of an object.

withoutVite()

Register a Vite handler that returns empty strings for all assets.

__invoke(string|array $entrypoints, string|null $buildDirectory = null)

No description

mixed
__call(string $method, array $parameters)

No description

string
__toString()

No description

useIntegrityKey(string|false $key)

No description

useHotFile(string $path)

No description

withEntryPoints(array $entryPoints)

No description

useScriptTagAttributes(array|callable $attributes)

No description

useStyleTagAttributes(array|callable $attributes)

No description

usePreloadTagAttributes(array|callable|false $attributes)

No description

array
preloadedAssets()

No description

string
content(string $asset, string|null $buildDirectory = null)

No description

string
asset(string $asset, string|null $buildDirectory = null)

No description

withHeaders(array $headers)

Define additional headers to be sent with the request.

withHeader(string $name, string $value)

Add a header to be sent with the request.

withoutHeader(string $name)

Remove a header from the request.

withoutHeaders(array $headers)

Remove headers from the request.

withToken(string $token, string $type = 'Bearer')

Add an authorization token for the request.

withBasicAuth(string $username, string $password)

Add a basic authentication header to the request with the given credentials.

withoutToken()

Remove the authorization token from the request.

flushHeaders()

Flush all the configured headers.

withServerVariables(array $server)

Define a set of server variables to be sent with the requests.

withoutMiddleware(null|array|string $middleware = null)

Disable middleware for the test.

withMiddleware(null|array|string $middleware = null)

Enable the given middleware for the test.

withCookies(array $cookies)

Define additional cookies to be sent with the request.

withCookie(string $name, string $value)

Add a cookie to be sent with the request.

withUnencryptedCookies(array $cookies)

Define additional cookies that will not be encrypted before sending with the request.

withUnencryptedCookie(string $name, string $value)

Add a cookie that will not be encrypted before sending with the request.

followingRedirects()

Automatically follow any redirects returned from the response.

withCredentials()

Include cookies and authorization headers for JSON requests.

disableCookieEncryption()

Disable automatic encryption of cookie values.

from(string $url)

Set the referer header and previous URL session value in order to simulate a previous request.

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.

withPrecognition()

Set the Precognition header to "true".

get(Stringable|string $uri, array $headers = [])

Visit the given URI with a GET request.

getJson(Stringable|string $uri, array $headers = [], int $options = 0)

Visit the given URI with a GET request, expecting a JSON response.

post(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a POST request.

postJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a POST request, expecting a JSON response.

put(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a PUT request.

putJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a PUT request, expecting a JSON response.

patch(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a PATCH request.

patchJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a PATCH request, expecting a JSON response.

delete(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a DELETE request.

deleteJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a DELETE request, expecting a JSON response.

options(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with an OPTIONS request.

optionsJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with an OPTIONS request, expecting a JSON response.

head(Stringable|string $uri, array $headers = [])

Visit the given URI with a HEAD request.

query(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a QUERY request.

queryJson(Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Visit the given URI with a QUERY request, expecting a JSON response.

json(string $method, Stringable|string $uri, array $data = [], array $headers = [], int $options = 0)

Call the given URI with a JSON request.

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.

string
prepareUrlForRequest(Stringable|string $uri)

Turn the given URI into a fully-qualified URL.

void
syncRequestContextToParent(Request $request)

Sync durable request Context state to the test coroutine.

array
sessionContextSnapshot(Request $request)

Get a snapshot of durable session Context state for the completed request.

array
sessionContextKeys()

Get durable session Context keys.

array
sessionStoreContextKeys(Store $session)

Get the Context keys for the given session store.

array
authenticationContextKeys()

Get durable authentication Context keys.

array
transformHeadersToServerVars(array $headers)

Transform headers array to array of $SERVER vars with HTTP* format.

string
formatServerHeaderKey(string $name)

Format the header name for the server array.

array
extractFilesFromDataArray(array $data)

Extract the file uploads from the given data array.

array
prepareCookiesForRequest()

If enabled, encrypt cookie values for request.

array
prepareCookiesForJsonRequest()

Prepare cookies for JSON requests.

followRedirects(mixed $response)

Follow a redirect chain until a non-redirect is received.

createTestRequest(Request $symfonyRequest)

Create the request instance used for testing from the given Symfony request.

createTestResponse(mixed $response, Request|null $request = null)

Create the test response instance from the given response.

void
dispatchRequestLifecycleEvent(string $eventClass, Request $request, Response|null $response = null)

Dispatch a request lifecycle event if enabled.

getWaiter()

Get the coroutine waiter for test requests.

actingAs(Authenticatable $user, string|null $guard = null)

Set the currently logged in user for the application.

actingAsGuest(string|null $guard = null)

Clear the currently logged in user for the application.

be(Authenticatable $user, string|null $guard = null)

Set the currently logged in user for the application.

assertAuthenticated(string|null $guard = null)

Assert that the user is authenticated.

assertGuest(string|null $guard = null)

Assert that the user is not authenticated.

bool
isAuthenticated(string|null $guard = null)

Return true if the user is authenticated, false otherwise.

assertAuthenticatedAs(Authenticatable $user, string|null $guard = null)

Assert that the user is authenticated as the given user.

assertCredentials(array $credentials, string|null $guard = null)

Assert that the given credentials are valid.

assertInvalidCredentials(array $credentials, string|null $guard = null)

Assert that the given credentials are invalid.

bool
hasCredentials(array $credentials, string|null $guard = null)

Return true if the credentials are valid, false otherwise.

artisan(string $command, array $parameters = [])

Alias of command method.

command(string $command, array $parameters = [])

Call Hypervel command and return code.

withoutMockingConsoleOutput()

Disable mocking the console output.

$this
assertDatabaseHas(Model>|Model|Model>|string $table, array $data = [], null|string $connection = null)

Assert that a given where condition exists in the database.

$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.

$this
assertDatabaseCount(Model|string $table, int $count, null|string $connection = null)

Assert the count of table entries.

$this
assertDatabaseEmpty(Model>|Model|Model>|Model|string>|string $table, null|string $connection = null)

Assert that the given table or tables has no entries.

$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".

$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".

$this
assertModelExists(Model>|Model|Model>|string $model)

Assert the given model exists in the database.

$this
assertModelMissing(Model>|Model|Model>|string $model)

Assert the given model does not exist in the database.

$this
expectsDatabaseQueryCount(int $expected, null|string $connection = null)

Specify the number of database queries that should occur throughout the test.

bool
isSoftDeletableModel(mixed $model)

Determine if the argument is a soft deletable model.

castAsJson(array|object|string $value, null|string $connection = null)

Cast a JSON string to a database compatible type.

getConnection(null|string $connection = null, null|Model>|Model|string $table = null)

Get the database connection.

string
getTable(Model>|Model|string $table)

Get the table name from the given model or string.

null|string
getTableConnection(Model>|Model|string $table)

Get the table connection specified in the given model.

string
getDeletedAtColumn(string $table, string $defaultColumnName = 'deleted_at')

Get the table column name used for soft deletes.

null|Model
newModelFor(Model|string $table)

Get the model entity from the given model or string.

seed(array|string $class = 'Database\Seeders\DatabaseSeeder')

Seed a given database connection.

void
setEnvironmentValue(string $key, string $value)

Set an environment variable for the current PHP process.

void
unsetEnvironmentValue(string $key)

Unset an environment variable for the current PHP process.

string
firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

array
firstClosureParameterTypes(Closure $closure)

Get the class names of the first parameter of the given Closure, including union types.

array
closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

array
closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

handleExceptions(array $exceptions)

Only handle the given exceptions via the exception handler.

handleValidationExceptions()

Only handle validation exceptions via the exception handler.

withoutExceptionHandling(array $except = [])

Disable exception handling for the test.

__construct(ExceptionHandler $originalHandler, array $except = [])

No description

void
report(Throwable $e)

Report or log an exception.

bool
shouldReport(Throwable $e)

Determine if the exception should be reported.

Response
render(Request $request, Throwable $e)

Render an exception into an HTTP response.

void
renderForConsole(OutputInterface $output, Throwable $e)

Render an exception to the console.

void
afterResponse(callable $callback)

Register a callback to be called after an HTTP error response is rendered.

void
assertRouteMiddlewareRunsBefore(string $routeName, string $before, string $after)

Assert route middleware runtime order.

array
resolvedMiddlewareForRoute(string $routeName)

Get resolved runtime middleware for a named route.

withSession(array $data)

Set the session to the given array.

session(array $data)

Set the session to the given array.

startSession()

Start the session for the application.

flushSession()

Flush all of the current session data.

mixed
freezeTime(null|callable $callback = null)

Freeze time.

mixed
freezeSecond(null|callable $callback = null)

Freeze time at the beginning of the current second.

travel(int $value)

Begin travelling to another time.

mixed
travelTo(null|bool|CarbonInterface|Closure|DateTimeInterface|string $date, null|callable $callback = null)

Travel to another time.

CarbonInterface
travelBack()

Travel back to the current time.

void
setUpTheTestEnvironment()

Set up the test environment.

void
tearDownTheTestEnvironment()

Clean up the testing environment before the next test.

array
setUpTraits()

Boot the testing helper traits.

void
setUpDatabaseTraits(array $uses)

Set up database-related testing traits.

static void
tearDownAfterClassUsingTestCase()

Clean up the testing environment before the next test case.

afterApplicationCreated(callable $callback)

Register a callback to be run after the application is created.

beforeApplicationDestroyed(callable $callback)

Register a callback to be run before the application is destroyed.

callBeforeApplicationDestroyedCallbacks()

Execute the application's pre-destruction callbacks.

void
preserveTransactionContext()

Preserve transaction manager context for the test coroutine.

void
runInCoroutine(callable $callback)

Ensure callback is executed in coroutine.

view(string $view, Arrayable|array $data = [])

Create a new TestView from the given view.

blade(string $template, Arrayable|array $data = [])

Render the contents of the given Blade template string.

component(string $componentClass, Arrayable|array $data = [])

Render the given view component.

withViewErrors(array $errors, string $key = 'default')

Populate the shared view error bag with the given errors.

$this
expectsEvents(array|string $events)

Specify a list of events that should be fired for the given operation.

$this
doesntExpectEvents(array|string $events)

Specify a list of events that should not be fired for the given operation.

$this
withoutEvents()

Mock the event dispatcher so all events are silenced and collected.

array
getFiredEvents(array $events)

Filter the given events against the fired events.

array
getDispatched(array $classes, array $dispatched)

Filter the given classes against an array of dispatched classes.

bool
wasDispatched(string $needle, array $haystack)

Check if the given class exists in an array of dispatched classes.

mixed
invokeTestMethod(string $methodName, array $testArguments)

Invoke the test method inside a Swoole coroutine container.

bool
runsTestsInCoroutine()

Determine whether tests run in a coroutine.

bool
shouldBootFrameworkForTest()

Determine if framework lifecycle hooks should run for this test.

void
invokeSetupInCoroutine()

No description

void
invokeTearDownInCoroutine(callable $capture)

No description

void
clearNonCoroutineTransactionContext()

Clear transaction context from non-coroutine storage before test starts.

void
cleanupTestContext()

Clean up Context keys that cause test pollution.

void
tearDownTheTestEnvironmentUsingMockery()

Tear down the testing environment using Mockery.

void
setUpFaker()

Set up the Faker instance.

Generator
faker(string|null $locale = null)

Get the default Faker instance for a given locale.

Generator
makeFaker(string|null $locale = null)

Create a Faker instance for the given locale.

void
setUp()

Setup the test environment.

void
refreshApplication()

Refresh the application instance.

createApplication()

Create the application instance.

void
tearDown()

Clean up the testing environment before the next test.

bool
withoutBootingFramework()

Determine if the test method should run without booting the framework.

from  TestCase
static void
tearDownAfterClass()

Clean up the testing environment before the next test case.

void
configureParallelDatabaseName(mixed $app)

Rewrite the default connection's database name for parallel testing.

void
ensureParallelDatabaseExists()

Ensure the per-worker database exists, creating it if needed.

bool
shouldManageParallelDatabase(mixed $driver, string $database)

Determine if the database should be managed for parallel testing.

string
parallelTestDatabase(string $database, string $token)

Get the per-worker test database name.

static bool
usesTestingConcern(string|null $trait = null)

Check if the test case uses a specific trait.

static bool
usesRefreshDatabaseTestingConcern()

Determine if the test case uses refresh-database testing concerns.

static array
cachedUsesForTestCase()

Cache and return traits used by test case.

static void
usesTestingFeature(object $attribute, int $flag = Attribute::TARGET_CLASS)

Programmatically add a testing feature attribute.

static Collection
resolvePhpUnitAttributesForMethod(string $className, string|null $methodName = null)

Resolve PHPUnit method attributes for specific method.

void
setUpTheTestEnvironmentUsingTestCase()

Execute BeforeEach lifecycle attributes.

void
tearDownTheTestEnvironmentUsingTestCase()

Execute AfterEach lifecycle attributes.

static void
setUpBeforeClassUsingTestCase()

Execute BeforeAll lifecycle attributes.

bool
isRunningTestCase()

Determine if the object is running as a PHPUnit test case.

string|null
resolvePhpUnitTestClassName()

Resolve the PHPUnit test class name.

string|null
resolvePhpUnitTestMethodName()

Resolve the PHPUnit test method name.

resolvePhpUnitAttributes()

Resolve and cache PHPUnit attributes for current test.

void
setUpTheEnvironmentUsing(Closure $setUp)

Define the setUp environment using callback.

void
tearDownTheEnvironmentUsing(Closure $tearDown)

Define the tearDown environment using callback.

static void
setUpBeforeClassUsingPHPUnit()

Cache uses for test case before class runs.

static void
tearDownAfterClassUsingPHPUnit()

Clear PHPUnit caches after class teardown.

bool
isRunningTestCaseUsingPest()

Determine if the trait is used within testing using Pest.

static bool
isRunningViaPestPrinter(object|string $object)

Determine if the object implements Pest test runner.

static string|null
applicationBasePathUsingWorkbench()

Get Application's base path.

array|null
ignorePackageDiscoveriesFromUsingWorkbench()

Ignore package discovery from.

array|null
getPackageBootstrappersUsingWorkbench(object $app)

Get package bootstrapper.

array|null
getPackageProvidersUsingWorkbench(object $app)

Get package providers.

string
applicationConsoleKernelUsingWorkbench(object $app)

Resolve application Console Kernel implementation.

string
applicationHttpKernelUsingWorkbench(object $app)

Get application HTTP Kernel implementation using Workbench.

string
applicationExceptionHandlerUsingWorkbench(object $app)

Get application HTTP exception handler using Workbench.

static Config|null
cachedConfigurationForWorkbench()

Define or get the cached uses for test case.

string|false
getApplicationBootstrapFile(string $filename)

Get application bootstrap file path (if exists).

bool
hasCustomApplicationKernels()

Determine if application is using a custom application kernels.

bool
usesTestbenchDefaultSkeleton()

Determine if application is bootstrapped using Testbench's default skeleton.

string
getApplicationBasePath()

Get the application's base path.

static string
applicationBasePath()

Get the base path for the application.

array
ignorePackageDiscoveriesFrom()

Ignore package discovery from.

array
getPackageProviders(Application $app)

Get package providers.

array
getPackageBootstrappers(Application $app)

Get package bootstrappers.

array
getApplicationProviders(Application $app)

Get application providers.

string|null
getApplicationTimezone(Application $app)

Get the application timezone.

array
overrideApplicationProviders(Application $app)

Override application providers.

array
getPackageAliases(Application $app)

Get package aliases.

array
overrideApplicationBindings(Application $app)

Override application bindings.

void
defineEnvironment(Application $app)

Define environment setup.

resolveApplication()

Resolve the application instance.

void
resolveApplicationBindings(Application $app)

Resolve application bindings.

void
resolveApplicationExceptionHandler(Application $app)

Resolve application HTTP exception handler.

void
resolveApplicationCore(Application $app)

Resolve application core environment.

void
resolveApplicationEnvironmentVariables(Application $app)

Resolve application environment variables.

maskInheritedApplicationEnvironment()

Mask inherited framework APP_ENV for Testbench applications that opt out of loading env files.

bool
hasConfiguredApplicationEnvironmentVariable(string $key)

Determine if the current test explicitly configured an environment variable.

void
resolveApplicationHttpKernel(Application $app)

Resolve application HTTP kernel implementation.

void
resolveApplicationHttpMiddlewares(Application $app)

Resolve application HTTP default middlewares.

void
resolveApplicationConsoleKernel(Application $app)

Resolve application console kernel implementation.

void
resolveApplicationConfiguration(Application $app)

Load configuration and register package providers/aliases.

void
resolveApplicationProviders(Application $app)

Resolve the final application provider list.

void
resolveApplicationBootstrappers(Application $app)

Run bootstrappers individually with defineEnvironment() inserted.

void
refreshApplicationRouteNameLookups(Application $app)

Refresh route name lookups now and whenever the URL generator is resolved.

void
registerPackageAliases(Application $app)

Register package aliases into config.

void
configureParallelCachePaths()

Configure worker-specific cache paths for parallel testing.

string|null
paraTestWorkerToken()

Get the current ParaTest worker token before the application exists.

void
markTestSkippedUnless(bool|Closure|null $condition, string $message)

Mark the test as skipped when condition is not equivalent to true.

void
markTestSkippedWhen(bool|Closure|null $condition, string $message)

Mark the test as skipped when condition is equivalent to true.

parseTestMethodAttributes(Application $app, string $attribute)

Parse and execute test method attributes of a specific type.

void
setUpDatabaseRequirements(Closure $callback)

Setup database requirements.

bool
usesSqliteInMemoryDatabaseConnection(string|null $connection = null)

Determine if using in-memory SQLite database connection.

void
defineDatabaseMigrations()

Define database migrations.

void
defineDatabaseMigrationsAfterDatabaseRefreshed()

Define database migrations after database refreshed.

void
destroyDatabaseMigrations()

Destroy database migrations.

void
defineDatabaseSeeders()

Define database seeders.

void
setUpApplicationRoutes(Application $app)

Setup application routes.

void
defineRoutes(Router $router)

Define routes setup.

void
defineWebRoutes(Router $router)

Define web routes setup.

void
defineStashRoutes(Closure|string $route)

Define stash routes setup.

void
defineCacheRoutes(Closure|string $route, bool $cached = true)

Define cache routes setup.

void
requireApplicationCachedRoutes(Filesystem $files, bool $cached)

Require application cached routes.

void
registerTestbenchRouteCleanup(Filesystem $files)

Register cleanup for route files and route cache written by this test.

string
testbenchRouteFilePath(string $basePath)

Get a route file path owned by this test instance.

void
loadMigrationsFrom(array|string $paths)

No description

array
resolvePackageMigrationsOptions(array|string $paths = [])

No description

void
loadHypervelMigrations(array|string $database = [])

Migrate Hypervel's default migrations.

void
runHypervelMigrations(array|string $database = [])

Migrate all Hypervel migrations.

array
resolveHypervelMigrationsOptions(array|string $database = [])

No description

void
reloadApplication()

Reload the application instance.

from  Testing
void
preservePackageManifestCache()

Preserve the package manifest cache for the duration of the test.

static void
setUpBeforeClass()

Prepare the testing environment before the running the test case.

void
refreshDatabase()

No description

void
runDatabaseMigrations()

No description

void
beginDatabaseTransaction()

No description

void
disableMiddlewareForAllTests()

No description

void
disableEventsForAllTests()

No description

Details

protected mixed swap(string $abstract, mixed $instance)

Register an instance of an object in the container.

Parameters

string $abstract
mixed $instance

Return Value

mixed

protected mixed instance(string $abstract, mixed $instance)

Register an instance of an object in the container.

Parameters

string $abstract
mixed $instance

Return Value

mixed

protected MockInterface mock(string $abstract, Closure|null $mock = null)

Mock an instance of an object in the container.

Parameters

string $abstract
Closure|null $mock

Return Value

MockInterface

protected MockInterface partialMock(string $abstract, Closure|null $mock = null)

Mock a partial instance of an object in the container.

Parameters

string $abstract
Closure|null $mock

Return Value

MockInterface

protected MockInterface spy(string $abstract, Closure|null $mock = null)

Spy an instance of an object in the container.

Parameters

string $abstract
Closure|null $mock

Return Value

MockInterface

protected InteractsWithContainer forgetMock(string $abstract)

Instruct the container to forget a previously mocked / spied instance of an object.

Parameters

string $abstract

Return Value

InteractsWithContainer

protected InteractsWithContainer withoutVite()

Register a Vite handler that returns empty strings for all assets.

Return Value

InteractsWithContainer

HtmlString __invoke(string|array $entrypoints, string|null $buildDirectory = null)

No description

Parameters

string|array $entrypoints
string|null $buildDirectory

Return Value

HtmlString

mixed __call(string $method, array $parameters)

No description

Parameters

string $method
array $parameters

Return Value

mixed

string __toString()

No description

Return Value

string

InteractsWithContainer useIntegrityKey(string|false $key)

No description

Parameters

string|false $key

Return Value

InteractsWithContainer

InteractsWithContainer useBuildDirectory(string $path)

No description

Parameters

string $path

Return Value

InteractsWithContainer

InteractsWithContainer useHotFile(string $path)

No description

Parameters

string $path

Return Value

InteractsWithContainer

InteractsWithContainer withEntryPoints(array $entryPoints)

No description

Parameters

array $entryPoints

Return Value

InteractsWithContainer

InteractsWithContainer useScriptTagAttributes(array|callable $attributes)

No description

Parameters

array|callable $attributes

Return Value

InteractsWithContainer

InteractsWithContainer useStyleTagAttributes(array|callable $attributes)

No description

Parameters

array|callable $attributes

Return Value

InteractsWithContainer

InteractsWithContainer usePreloadTagAttributes(array|callable|false $attributes)

No description

Parameters

array|callable|false $attributes

Return Value

InteractsWithContainer

array preloadedAssets()

No description

Return Value

array

HtmlString reactRefresh()

No description

Return Value

HtmlString

string content(string $asset, string|null $buildDirectory = null)

No description

Parameters

string $asset
string|null $buildDirectory

Return Value

string

string asset(string $asset, string|null $buildDirectory = null)

No description

Parameters

string $asset
string|null $buildDirectory

Return Value

string

in MakesHttpRequests at line 73
MakesHttpRequests withHeaders(array $headers)

Define additional headers to be sent with the request.

Parameters

array $headers

Return Value

MakesHttpRequests

in MakesHttpRequests at line 83
MakesHttpRequests withHeader(string $name, string $value)

Add a header to be sent with the request.

Parameters

string $name
string $value

Return Value

MakesHttpRequests

in MakesHttpRequests at line 93
MakesHttpRequests withoutHeader(string $name)

Remove a header from the request.

Parameters

string $name

Return Value

MakesHttpRequests

in MakesHttpRequests at line 103
MakesHttpRequests withoutHeaders(array $headers)

Remove headers from the request.

Parameters

array $headers

Return Value

MakesHttpRequests

in MakesHttpRequests at line 115
MakesHttpRequests withToken(string $token, string $type = 'Bearer')

Add an authorization token for the request.

Parameters

string $token
string $type

Return Value

MakesHttpRequests

in MakesHttpRequests at line 123
MakesHttpRequests withBasicAuth(string $username, string $password)

Add a basic authentication header to the request with the given credentials.

Parameters

string $username
string $password

Return Value

MakesHttpRequests

in MakesHttpRequests at line 131
MakesHttpRequests withoutToken()

Remove the authorization token from the request.

Return Value

MakesHttpRequests

in MakesHttpRequests at line 139
MakesHttpRequests flushHeaders()

Flush all the configured headers.

Return Value

MakesHttpRequests

in MakesHttpRequests at line 149
MakesHttpRequests withServerVariables(array $server)

Define a set of server variables to be sent with the requests.

Parameters

array $server

Return Value

MakesHttpRequests

in MakesHttpRequests at line 161
MakesHttpRequests withoutMiddleware(null|array|string $middleware = null)

Disable middleware for the test.

Parameters

null|array|string $middleware

Return Value

MakesHttpRequests

in MakesHttpRequests at line 181
MakesHttpRequests withMiddleware(null|array|string $middleware = null)

Enable the given middleware for the test.

Parameters

null|array|string $middleware

Return Value

MakesHttpRequests

in MakesHttpRequests at line 199
MakesHttpRequests withCookies(array $cookies)

Define additional cookies to be sent with the request.

Parameters

array $cookies

Return Value

MakesHttpRequests

in MakesHttpRequests at line 209
MakesHttpRequests withCookie(string $name, string $value)

Add a cookie to be sent with the request.

Parameters

string $name
string $value

Return Value

MakesHttpRequests

in MakesHttpRequests at line 219
MakesHttpRequests withUnencryptedCookies(array $cookies)

Define additional cookies that will not be encrypted before sending with the request.

Parameters

array $cookies

Return Value

MakesHttpRequests

in MakesHttpRequests at line 229
MakesHttpRequests withUnencryptedCookie(string $name, string $value)

Add a cookie that will not be encrypted before sending with the request.

Parameters

string $name
string $value

Return Value

MakesHttpRequests

in MakesHttpRequests at line 239
MakesHttpRequests followingRedirects()

Automatically follow any redirects returned from the response.

Return Value

MakesHttpRequests

in MakesHttpRequests at line 249
MakesHttpRequests withCredentials()

Include cookies and authorization headers for JSON requests.

Return Value

MakesHttpRequests

in MakesHttpRequests at line 259
MakesHttpRequests disableCookieEncryption()

Disable automatic encryption of cookie values.

Return Value

MakesHttpRequests

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.

Parameters

string $url

Return Value

MakesHttpRequests

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.

Parameters

BackedEnum|string $name
mixed $parameters

Return Value

MakesHttpRequests

in MakesHttpRequests at line 287
MakesHttpRequests withPrecognition()

Set the Precognition header to "true".

Return Value

MakesHttpRequests

in MakesHttpRequests at line 295
TestResponse get(Stringable|string $uri, array $headers = [])

Visit the given URI with a GET request.

Parameters

Stringable|string $uri
array $headers

Return Value

TestResponse

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.

Parameters

Stringable|string $uri
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 314
TestResponse post(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a POST request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

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.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 333
TestResponse put(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a PUT request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

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.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 352
TestResponse patch(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a PATCH request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

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.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 371
TestResponse delete(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a DELETE request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

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.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 390
TestResponse options(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with an OPTIONS request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

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.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

in MakesHttpRequests at line 409
TestResponse head(Stringable|string $uri, array $headers = [])

Visit the given URI with a HEAD request.

Parameters

Stringable|string $uri
array $headers

Return Value

TestResponse

in MakesHttpRequests at line 420
TestResponse query(Stringable|string $uri, array $data = [], array $headers = [])

Visit the given URI with a QUERY request.

Parameters

Stringable|string $uri
array $data
array $headers

Return Value

TestResponse

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.

Parameters

Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

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.

Parameters

string $method
Stringable|string $uri
array $data
array $headers
int $options

Return Value

TestResponse

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().

Parameters

string $method
Stringable|string $uri
array $parameters
array $cookies
array $files
array $server
string|null $content

Return Value

TestResponse

in MakesHttpRequests at line 546
protected string prepareUrlForRequest(Stringable|string $uri)

Turn the given URI into a fully-qualified URL.

Parameters

Stringable|string $uri

Return Value

string

in MakesHttpRequests at line 560
protected void syncRequestContextToParent(Request $request)

Sync durable request Context state to the test coroutine.

Parameters

Request $request

Return Value

void

in MakesHttpRequests at line 577
protected array sessionContextSnapshot(Request $request)

Get a snapshot of durable session Context state for the completed request.

Parameters

Request $request

Return Value

array

in MakesHttpRequests at line 600
protected array sessionContextKeys()

Get durable session Context keys.

Return Value

array

in MakesHttpRequests at line 619
protected array sessionStoreContextKeys(Store $session)

Get the Context keys for the given session store.

Parameters

Store $session

Return Value

array

in MakesHttpRequests at line 635
protected array authenticationContextKeys()

Get durable authentication Context keys.

Return Value

array

in MakesHttpRequests at line 653
protected array transformHeadersToServerVars(array $headers)

Transform headers array to array of $SERVER vars with HTTP* format.

Parameters

array $headers

Return Value

array

in MakesHttpRequests at line 665
protected string formatServerHeaderKey(string $name)

Format the header name for the server array.

Parameters

string $name

Return Value

string

in MakesHttpRequests at line 677
protected array extractFilesFromDataArray(array $data)

Extract the file uploads from the given data array.

Parameters

array $data

Return Value

array

in MakesHttpRequests at line 701
protected array prepareCookiesForRequest()

If enabled, encrypt cookie values for request.

Return Value

array

in MakesHttpRequests at line 716
protected array prepareCookiesForJsonRequest()

Prepare cookies for JSON requests.

Return Value

array

in MakesHttpRequests at line 725
protected TestResponse followRedirects(mixed $response)

Follow a redirect chain until a non-redirect is received.

Parameters

mixed $response

Return Value

TestResponse

in MakesHttpRequests at line 739
protected Request createTestRequest(Request $symfonyRequest)

Create the request instance used for testing from the given Symfony request.

Parameters

Request $symfonyRequest

Return Value

Request

in MakesHttpRequests at line 748
protected TestResponse createTestResponse(mixed $response, Request|null $request = null)

Create the test response instance from the given response.

Parameters

mixed $response
Request|null $request

Return Value

TestResponse

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.

Parameters

string $eventClass
Request $request
Response|null $response

Return Value

void

in MakesHttpRequests at line 790
protected Waiter getWaiter()

Get the coroutine waiter for test requests.

Return Value

Waiter

InteractsWithAuthentication actingAs(Authenticatable $user, string|null $guard = null)

Set the currently logged in user for the application.

Parameters

Authenticatable $user
string|null $guard

Return Value

InteractsWithAuthentication

InteractsWithAuthentication actingAsGuest(string|null $guard = null)

Clear the currently logged in user for the application.

Parameters

string|null $guard

Return Value

InteractsWithAuthentication

InteractsWithAuthentication be(Authenticatable $user, string|null $guard = null)

Set the currently logged in user for the application.

Parameters

Authenticatable $user
string|null $guard

Return Value

InteractsWithAuthentication

InteractsWithAuthentication assertAuthenticated(string|null $guard = null)

Assert that the user is authenticated.

Parameters

string|null $guard

Return Value

InteractsWithAuthentication

InteractsWithAuthentication assertGuest(string|null $guard = null)

Assert that the user is not authenticated.

Parameters

string|null $guard

Return Value

InteractsWithAuthentication

protected bool isAuthenticated(string|null $guard = null)

Return true if the user is authenticated, false otherwise.

Parameters

string|null $guard

Return Value

bool

InteractsWithAuthentication assertAuthenticatedAs(Authenticatable $user, string|null $guard = null)

Assert that the user is authenticated as the given user.

Parameters

Authenticatable $user
string|null $guard

Return Value

InteractsWithAuthentication

InteractsWithAuthentication assertCredentials(array $credentials, string|null $guard = null)

Assert that the given credentials are valid.

Parameters

array $credentials
string|null $guard

Return Value

InteractsWithAuthentication

InteractsWithAuthentication assertInvalidCredentials(array $credentials, string|null $guard = null)

Assert that the given credentials are invalid.

Parameters

array $credentials
string|null $guard

Return Value

InteractsWithAuthentication

protected bool hasCredentials(array $credentials, string|null $guard = null)

Return true if the credentials are valid, false otherwise.

Parameters

array $credentials
string|null $guard

Return Value

bool

int|PendingCommand artisan(string $command, array $parameters = [])

Alias of command method.

Parameters

string $command
array $parameters

Return Value

int|PendingCommand

int|PendingCommand command(string $command, array $parameters = [])

Call Hypervel command and return code.

Parameters

string $command
array $parameters

Return Value

int|PendingCommand

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.

Return Value

InteractsWithConsole

protected $this assertDatabaseHas(Model>|Model|Model>|string $table, array $data = [], null|string $connection = null)

Assert that a given where condition exists in the database.

Parameters

Model>|Model|Model>|string $table
array $data
null|string $connection

Return Value

$this

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.

Parameters

Model>|Model|Model>|string $table
array $data
null|string $connection

Return Value

$this

protected $this assertDatabaseCount(Model|string $table, int $count, null|string $connection = null)

Assert the count of table entries.

Parameters

Model|string $table
int $count
null|string $connection

Return Value

$this

protected $this assertDatabaseEmpty(Model>|Model|Model>|Model|string>|string $table, null|string $connection = null)

Assert that the given table or tables has no entries.

Parameters

Model>|Model|Model>|Model|string>|string $table
null|string $connection

Return Value

$this

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".

Parameters

Model>|Model|Model>|Model|string>|string $table
array $data
null|string $connection
null|string $deletedAtColumn

Return Value

$this

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".

Parameters

Model>|Model|Model>|Model|string>|string $table
array $data
null|string $connection
null|string $deletedAtColumn

Return Value

$this

protected $this assertModelExists(Model>|Model|Model>|string $model)

Assert the given model exists in the database.

Parameters

Model>|Model|Model>|string $model

Return Value

$this

protected $this assertModelMissing(Model>|Model|Model>|string $model)

Assert the given model does not exist in the database.

Parameters

Model>|Model|Model>|string $model

Return Value

$this

$this expectsDatabaseQueryCount(int $expected, null|string $connection = null)

Specify the number of database queries that should occur throughout the test.

Parameters

int $expected
null|string $connection

Return Value

$this

protected bool isSoftDeletableModel(mixed $model)

Determine if the argument is a soft deletable model.

Parameters

mixed $model

Return Value

bool

Expression castAsJson(array|object|string $value, null|string $connection = null)

Cast a JSON string to a database compatible type.

Parameters

array|object|string $value
null|string $connection

Return Value

Expression

protected Connection getConnection(null|string $connection = null, null|Model>|Model|string $table = null)

Get the database connection.

Parameters

null|string $connection
null|Model>|Model|string $table

Return Value

Connection

protected string getTable(Model>|Model|string $table)

Get the table name from the given model or string.

Parameters

Model>|Model|string $table

Return Value

string

protected null|string getTableConnection(Model>|Model|string $table)

Get the table connection specified in the given model.

Parameters

Model>|Model|string $table

Return Value

null|string

protected string getDeletedAtColumn(string $table, string $defaultColumnName = 'deleted_at')

Get the table column name used for soft deletes.

Parameters

string $table
string $defaultColumnName

Return Value

string

protected null|Model newModelFor(Model|string $table)

Get the model entity from the given model or string.

Parameters

Model|string $table

Return Value

null|Model

InteractsWithDatabase seed(array|string $class = 'Database\Seeders\DatabaseSeeder')

Seed a given database connection.

Parameters

array|string $class

Return Value

InteractsWithDatabase

protected InteractsWithDeprecationHandling withDeprecationHandling()

Restore deprecation handling.

protected InteractsWithDeprecationHandling withoutDeprecationHandling()

Disable deprecation handling for the test.

protected void setEnvironmentValue(string $key, string $value)

Set an environment variable for the current PHP process.

Parameters

string $key
string $value

Return Value

void

protected void unsetEnvironmentValue(string $key)

Unset an environment variable for the current PHP process.

Parameters

string $key

Return Value

void

in ReflectsClosures at line 25
protected string firstClosureParameterType(Closure $closure)

Get the class name of the first parameter of the given Closure.

Parameters

Closure $closure

Return Value

string

Exceptions

ReflectionException
RuntimeException

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.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException
RuntimeException

in ReflectsClosures at line 74
protected array closureParameterTypes(Closure $closure)

Get the class names / types of the parameters of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

in ReflectsClosures at line 94
protected array closureReturnTypes(Closure $closure)

Get the class names / types of the return type of the given Closure.

Parameters

Closure $closure

Return Value

array

Exceptions

ReflectionException

protected InteractsWithExceptionHandling withExceptionHandling()

Restore exception handling.

protected InteractsWithExceptionHandling handleExceptions(array $exceptions)

Only handle the given exceptions via the exception handler.

Parameters

array $exceptions

Return Value

InteractsWithExceptionHandling

protected InteractsWithExceptionHandling handleValidationExceptions()

Only handle validation exceptions via the exception handler.

protected InteractsWithExceptionHandling withoutExceptionHandling(array $except = [])

Disable exception handling for the test.

Parameters

array $except

Return Value

InteractsWithExceptionHandling

__construct(ExceptionHandler $originalHandler, array $except = [])

No description

Parameters

ExceptionHandler $originalHandler
array $except

void report(Throwable $e)

Report or log an exception.

Parameters

Throwable $e

Return Value

void

bool shouldReport(Throwable $e)

Determine if the exception should be reported.

Parameters

Throwable $e

Return Value

bool

Response render(Request $request, Throwable $e)

Render an exception into an HTTP response.

Parameters

Request $request
Throwable $e

Return Value

Response

Exceptions

Throwable

void renderForConsole(OutputInterface $output, Throwable $e)

Render an exception to the console.

Parameters

OutputInterface $output
Throwable $e

Return Value

void

void afterResponse(callable $callback)

Register a callback to be called after an HTTP error response is rendered.

Parameters

callable $callback

Return Value

void

protected void assertRouteMiddlewareRunsBefore(string $routeName, string $before, string $after)

Assert route middleware runtime order.

Parameters

string $routeName
string $before
string $after

Return Value

void

protected array resolvedMiddlewareForRoute(string $routeName)

Get resolved runtime middleware for a named route.

Parameters

string $routeName

Return Value

array

InteractsWithSession withSession(array $data)

Set the session to the given array.

Parameters

array $data

Return Value

InteractsWithSession

InteractsWithSession session(array $data)

Set the session to the given array.

Parameters

array $data

Return Value

InteractsWithSession

protected InteractsWithSession startSession()

Start the session for the application.

Return Value

InteractsWithSession

InteractsWithSession flushSession()

Flush all of the current session data.

Return Value

InteractsWithSession

in InteractsWithTime at line 22
mixed freezeTime(null|callable $callback = null)

Freeze time.

Parameters

null|callable $callback

Return Value

mixed

in InteractsWithTime at line 35
mixed freezeSecond(null|callable $callback = null)

Freeze time at the beginning of the current second.

Parameters

null|callable $callback

Return Value

mixed

in InteractsWithTime at line 45
Wormhole travel(int $value)

Begin travelling to another time.

Parameters

int $value

Return Value

Wormhole

in InteractsWithTime at line 57
mixed travelTo(null|bool|CarbonInterface|Closure|DateTimeInterface|string $date, null|callable $callback = null)

Travel to another time.

Parameters

null|bool|CarbonInterface|Closure|DateTimeInterface|string $date
null|callable $callback

Return Value

mixed

in InteractsWithTime at line 73
CarbonInterface travelBack()

Travel back to the current time.

Return Value

CarbonInterface

protected void setUpTheTestEnvironment()

internal  
 

Set up the test environment.

Return Value

void

protected void tearDownTheTestEnvironment()

internal  
 

Clean up the testing environment before the next test.

Return Value

void

Exceptions

Throwable

protected array setUpTraits()

Boot the testing helper traits.

Return Value

array

at line 144
protected void setUpDatabaseTraits(array $uses)

Set up database-related testing traits.

Wraps migration traits in setUpDatabaseRequirements() so that testbench attributes (RequiresDatabase, WithConfig, WithMigration) are processed before migrations run.

Parameters

array $uses

Return Value

void

static void tearDownAfterClassUsingTestCase()

internal  
 

Clean up the testing environment before the next test case.

Return Value

void

afterApplicationCreated(callable $callback)

Register a callback to be run after the application is created.

Parameters

callable $callback

protected beforeApplicationDestroyed(callable $callback)

Register a callback to be run before the application is destroyed.

Parameters

callable $callback

protected callBeforeApplicationDestroyedCallbacks()

Execute the application's pre-destruction callbacks.

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().

Return Value

void

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).

Parameters

callable $callback

Return Value

void

in InteractsWithViews at line 22
protected TestView view(string $view, Arrayable|array $data = [])

Create a new TestView from the given view.

Parameters

string $view
Arrayable|array $data

Return Value

TestView

in InteractsWithViews at line 33
protected TestView blade(string $template, Arrayable|array $data = [])

Render the contents of the given Blade template string.

Parameters

string $template
Arrayable|array $data

Return Value

TestView

in InteractsWithViews at line 78
protected TestComponent component(string $componentClass, Arrayable|array $data = [])

Render the given view component.

Parameters

string $componentClass
Arrayable|array $data

Return Value

TestComponent

in InteractsWithViews at line 97
protected InteractsWithViews withViewErrors(array $errors, string $key = 'default')

Populate the shared view error bag with the given errors.

Parameters

array $errors
string $key

Return Value

InteractsWithViews

$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.

Parameters

array|string $events

Return Value

$this

Exceptions

Exception

$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.

Parameters

array|string $events

Return Value

$this

protected $this withoutEvents()

Mock the event dispatcher so all events are silenced and collected.

Return Value

$this

protected array getFiredEvents(array $events)

Filter the given events against the fired events.

Parameters

array $events

Return Value

array

protected array getDispatched(array $classes, array $dispatched)

Filter the given classes against an array of dispatched classes.

Parameters

array $classes
array $dispatched

Return Value

array

protected bool wasDispatched(string $needle, array $haystack)

Check if the given class exists in an array of dispatched classes.

Parameters

string $needle
array $haystack

Return Value

bool

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).

Parameters

string $methodName
array $testArguments

Return Value

mixed

protected bool runsTestsInCoroutine()

Determine whether tests run in a coroutine.

Return Value

bool

protected bool shouldBootFrameworkForTest()

Determine if framework lifecycle hooks should run for this test.

Return Value

bool

in RunTestsInCoroutine at line 104
protected void invokeSetupInCoroutine()

No description

Return Value

void

in RunTestsInCoroutine at line 119
protected void invokeTearDownInCoroutine(callable $capture)

No description

Parameters

callable $capture

Return Value

void

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).

Return Value

void

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).

Return Value

void

protected void tearDownTheTestEnvironmentUsingMockery()

Tear down the testing environment using Mockery.

Return Value

void

in WithFaker at line 20
protected void setUpFaker()

Set up the Faker instance.

Return Value

void

in WithFaker at line 28
protected Generator faker(string|null $locale = null)

Get the default Faker instance for a given locale.

Parameters

string|null $locale

Return Value

Generator

in WithFaker at line 36
protected Generator makeFaker(string|null $locale = null)

Create a Faker instance for the given locale.

Parameters

string|null $locale

Return Value

Generator

at line 54
protected void setUp()

Setup the test environment.

Return Value

void

at line 164
protected void refreshApplication()

Refresh the application instance.

Return Value

void

in CreatesApplication at line 180
Application createApplication()

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.

Return Value

Application

at line 172
protected void tearDown()

Clean up the testing environment before the next test.

Return Value

void

in TestCase at line 126
protected bool withoutBootingFramework()

Determine if the test method should run without booting the framework.

Return Value

bool

at line 259
static void tearDownAfterClass()

Clean up the testing environment before the next test case.

Return Value

void

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.

Parameters

mixed $app

Return Value

void

protected void ensureParallelDatabaseExists()

Ensure the per-worker database exists, creating it if needed.

Called from database testing traits (RefreshDatabase, DatabaseMigrations, 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.

Return Value

void

protected bool shouldManageParallelDatabase(mixed $driver, string $database)

Determine if the database should be managed for parallel testing.

Parameters

mixed $driver
string $database

Return Value

bool

protected string parallelTestDatabase(string $database, string $token)

Get the per-worker test database name.

Parameters

string $database
string $token

Return Value

string

static bool usesTestingConcern(string|null $trait = null)

Check if the test case uses a specific trait.

Parameters

string|null $trait

Return Value

bool

static bool usesRefreshDatabaseTestingConcern()

Determine if the test case uses refresh-database testing concerns.

Return Value

bool

static array cachedUsesForTestCase()

Cache and return traits used by test case.

Return Value

array

static void usesTestingFeature(object $attribute, int $flag = Attribute::TARGET_CLASS)

Programmatically add a testing feature attribute.

Parameters

object $attribute
int $flag

Return Value

void

abstract static protected Collection resolvePhpUnitAttributesForMethod(string $className, string|null $methodName = null)

Resolve PHPUnit method attributes for specific method.

Parameters

string $className
string|null $methodName

Return Value

Collection

protected void setUpTheTestEnvironmentUsingTestCase()

Execute BeforeEach lifecycle attributes.

Return Value

void

protected void tearDownTheTestEnvironmentUsingTestCase()

Execute AfterEach lifecycle attributes.

Return Value

void

static void setUpBeforeClassUsingTestCase()

Execute BeforeAll lifecycle attributes.

Return Value

void

bool isRunningTestCase()

Determine if the object is running as a PHPUnit test case.

Return Value

bool

string|null resolvePhpUnitTestClassName()

Resolve the PHPUnit test class name.

Return Value

string|null

string|null resolvePhpUnitTestMethodName()

Resolve the PHPUnit test method name.

Return Value

string|null

protected Collection resolvePhpUnitAttributes()

Resolve and cache PHPUnit attributes for current test.

Return Value

Collection

in InteractsWithPHPUnit at line 142
void setUpTheEnvironmentUsing(Closure $setUp)

Define the setUp environment using callback.

Parameters

Closure $setUp

Return Value

void

in InteractsWithPHPUnit at line 152
void tearDownTheEnvironmentUsing(Closure $tearDown)

Define the tearDown environment using callback.

Parameters

Closure $tearDown

Return Value

void

in InteractsWithPHPUnit at line 160
static void setUpBeforeClassUsingPHPUnit()

Cache uses for test case before class runs.

Return Value

void

in InteractsWithPHPUnit at line 168
static void tearDownAfterClassUsingPHPUnit()

Clear PHPUnit caches after class teardown.

Return Value

void

in InteractsWithPest at line 17
bool isRunningTestCaseUsingPest()

Determine if the trait is used within testing using Pest.

Return Value

bool

in InteractsWithPest at line 25
static protected bool isRunningViaPestPrinter(object|string $object)

Determine if the object implements Pest test runner.

Parameters

object|string $object

Return Value

bool

static string|null applicationBasePathUsingWorkbench()

internal  
 

Get Application's base path.

Return Value

string|null

array|null ignorePackageDiscoveriesFromUsingWorkbench()

internal  
 

Ignore package discovery from.

Return Value

array|null

protected array|null getPackageBootstrappersUsingWorkbench(object $app)

internal  
 

Get package bootstrapper.

Parameters

object $app

Return Value

array|null

protected array|null getPackageProvidersUsingWorkbench(object $app)

internal  
 

Get package providers.

Parameters

object $app

Return Value

array|null

protected string applicationConsoleKernelUsingWorkbench(object $app)

internal  
 

Resolve application Console Kernel implementation.

Parameters

object $app

Return Value

string

protected string applicationHttpKernelUsingWorkbench(object $app)

internal  
 

Get application HTTP Kernel implementation using Workbench.

Parameters

object $app

Return Value

string

protected string applicationExceptionHandlerUsingWorkbench(object $app)

internal  
 

Get application HTTP exception handler using Workbench.

Parameters

object $app

Return Value

string

static Config|null cachedConfigurationForWorkbench()

Define or get the cached uses for test case.

Return Value

Config|null

protected string|false getApplicationBootstrapFile(string $filename)

internal  
 

Get application bootstrap file path (if exists).

Parameters

string $filename

Return Value

string|false

protected bool hasCustomApplicationKernels()

internal  
 

Determine if application is using a custom application kernels.

Return Value

bool

protected bool usesTestbenchDefaultSkeleton()

Determine if application is bootstrapped using Testbench's default skeleton.

Return Value

bool

abstract protected string getApplicationBasePath()

Get the application's base path.

Return Value

string

in CreatesApplication at line 64
static string applicationBasePath()

Get the base path for the application.

Return Value

string

in CreatesApplication at line 74
array ignorePackageDiscoveriesFrom()

Ignore package discovery from.

Return Value

array

in CreatesApplication at line 92
protected array getPackageProviders(Application $app)

Get package providers.

Parameters

Application $app

Return Value

array

in CreatesApplication at line 102
protected array getPackageBootstrappers(Application $app)

Get package bootstrappers.

Parameters

Application $app

Return Value

array

in CreatesApplication at line 115
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.

Parameters

Application $app

Return Value

array

in CreatesApplication at line 123
protected string|null getApplicationTimezone(Application $app)

Get the application timezone.

Parameters

Application $app

Return Value

string|null

in CreatesApplication at line 136
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.

Parameters

Application $app

Return Value

array

in CreatesApplication at line 146
protected array getPackageAliases(Application $app)

Get package aliases.

Parameters

Application $app

Return Value

array

in CreatesApplication at line 156
protected array overrideApplicationBindings(Application $app)

Override application bindings.

Parameters

Application $app

Return Value

array

in CreatesApplication at line 167
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.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 209
protected Application resolveApplication()

Resolve the application instance.

Return Value

Application

in CreatesApplication at line 230
protected void resolveApplicationBindings(Application $app)

Resolve application bindings.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 240
protected void resolveApplicationExceptionHandler(Application $app)

Resolve application HTTP exception handler.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 248
protected void resolveApplicationCore(Application $app)

Resolve application core environment.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 258
protected void resolveApplicationEnvironmentVariables(Application $app)

Resolve application environment variables.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 299
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.

Return Value

Closure

in CreatesApplication at line 340
protected bool hasConfiguredApplicationEnvironmentVariable(string $key)

Determine if the current test explicitly configured an environment variable.

Parameters

string $key

Return Value

bool

in CreatesApplication at line 352
protected void resolveApplicationHttpKernel(Application $app)

Resolve application HTTP kernel implementation.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 360
protected void resolveApplicationHttpMiddlewares(Application $app)

Resolve application HTTP default middlewares.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 391
protected void resolveApplicationConsoleKernel(Application $app)

Resolve application console kernel implementation.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 405
protected void resolveApplicationConfiguration(Application $app)

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.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 453
protected void resolveApplicationProviders(Application $app)

Resolve the final application provider list.

Merges package providers, then applies overrides (replacements/removals) before writing the final list to config for RegisterProviders to use.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 482
protected void resolveApplicationBootstrappers(Application $app)

Run bootstrappers individually with defineEnvironment() inserted.

Equivalent to Orchestral's resolveApplicationBootstrappers().

Parameters

Application $app

Return Value

void

in CreatesApplication at line 538
protected void refreshApplicationRouteNameLookups(Application $app)

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.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 553
protected void registerPackageAliases(Application $app)

Register package aliases into config.

Parameters

Application $app

Return Value

void

in CreatesApplication at line 574
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.

Return Value

void

in CreatesApplication at line 592
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.

Return Value

string|null

in HandlesAssertions at line 19
protected void markTestSkippedUnless(bool|Closure|null $condition, string $message)

Mark the test as skipped when condition is not equivalent to true.

Parameters

bool|Closure|null $condition
string $message

Return Value

void

in HandlesAssertions at line 32
protected void markTestSkippedWhen(bool|Closure|null $condition, string $message)

Mark the test as skipped when condition is equivalent to true.

Parameters

bool|Closure|null $condition
string $message

Return Value

void

in HandlesAttributes at line 28
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.

Parameters

Application $app
string $attribute

Return Value

FeaturesCollection

in HandlesDatabases at line 27
protected void setUpDatabaseRequirements(Closure $callback)

Setup database requirements.

Parameters

Closure $callback

Return Value

void

in HandlesDatabases at line 76
protected bool usesSqliteInMemoryDatabaseConnection(string|null $connection = null)

Determine if using in-memory SQLite database connection.

Parameters

string|null $connection

Return Value

bool

in HandlesDatabases at line 98
protected void defineDatabaseMigrations()

Define database migrations.

Return Value

void

in HandlesDatabases at line 106
protected void defineDatabaseMigrationsAfterDatabaseRefreshed()

Define database migrations after database refreshed.

Return Value

void

in HandlesDatabases at line 114
protected void destroyDatabaseMigrations()

Destroy database migrations.

Return Value

void

in HandlesDatabases at line 122
protected void defineDatabaseSeeders()

Define database seeders.

Return Value

void

in HandlesRoutes at line 56
protected void setUpApplicationRoutes(Application $app)

Setup application routes.

Parameters

Application $app

Return Value

void

in HandlesRoutes at line 88
protected void defineRoutes(Router $router)

Define routes setup.

Parameters

Router $router

Return Value

void

in HandlesRoutes at line 96
protected void defineWebRoutes(Router $router)

Define web routes setup.

Parameters

Router $router

Return Value

void

in HandlesRoutes at line 104
protected void defineStashRoutes(Closure|string $route)

Define stash routes setup.

Parameters

Closure|string $route

Return Value

void

in HandlesRoutes at line 112
protected void defineCacheRoutes(Closure|string $route, bool $cached = true)

Define cache routes setup.

Parameters

Closure|string $route
bool $cached

Return Value

void

in HandlesRoutes at line 184
protected void requireApplicationCachedRoutes(Filesystem $files, bool $cached)

internal  
 

Require application cached routes.

Parameters

Filesystem $files
bool $cached

Return Value

void

in HandlesRoutes at line 208
protected void registerTestbenchRouteCleanup(Filesystem $files)

Register cleanup for route files and route cache written by this test.

Parameters

Filesystem $files

Return Value

void

in HandlesRoutes at line 234
protected string testbenchRouteFilePath(string $basePath)

Get a route file path owned by this test instance.

Parameters

string $basePath

Return Value

string

protected void setUpInteractsWithMigrations()

No description

Return Value

void

protected void tearDownInteractsWithMigrations()

No description

Return Value

void

protected void loadMigrationsFrom(array|string $paths)

No description

Parameters

array|string $paths

Return Value

void

protected array resolvePackageMigrationsOptions(array|string $paths = [])

internal  
 

No description

Parameters

array|string $paths

Return Value

array

protected void loadHypervelMigrations(array|string $database = [])

Migrate Hypervel's default migrations.

Parameters

array|string $database

Return Value

void

protected void runHypervelMigrations(array|string $database = [])

Migrate all Hypervel migrations.

Parameters

array|string $database

Return Value

void

protected array resolveHypervelMigrationsOptions(array|string $database = [])

internal  
 

No description

Parameters

array|string $database

Return Value

array

protected void resetApplicationArtisanCommands(Application $app)

No description

Parameters

Application $app

Return Value

void

in Testing at line 28
protected void reloadApplication()

Reload the application instance.

Return Value

void

at line 111
protected void preservePackageManifestCache()

Preserve the package manifest cache for the duration of the test.

Return Value

void

at line 244
static void setUpBeforeClass()

Prepare the testing environment before the running the test case.

Return Value

void

at line 35
void refreshDatabase()

No description

Return Value

void

at line 35
void runDatabaseMigrations()

No description

Return Value

void

at line 35
void beginDatabaseTransaction()

No description

Return Value

void

at line 35
void disableMiddlewareForAllTests()

No description

Return Value

void

at line 35
void disableEventsForAllTests()

No description

Return Value

void