trait TestDatabases (View source)

Properties

static protected bool $schemaIsUpToDate

Indicates if the test database schema is up to date.

Methods

void
bootTestDatabase()

Boot a test database.

array
ensureTestDatabaseExists(string $database)

Ensure a test database exists and returns its name.

void
ensureSchemaIsUpToDate()

Ensure the current database test schema is up to date.

void
usingDatabase(string $database, callable $callable)

Runs the given callable using the given database.

void
whenNotUsingInMemoryDatabase(callable $callback)

Apply the given callback when tests are not using in memory database.

void
switchToDatabase(string $database)

Switch to the given database.

string
testDatabase($database)

Returns the test database name.

Details

protected void bootTestDatabase()

Boot a test database.

Return Value

void

protected array ensureTestDatabaseExists(string $database)

Ensure a test database exists and returns its name.

Parameters

string $database

Return Value

array

protected void ensureSchemaIsUpToDate()

Ensure the current database test schema is up to date.

Return Value

void

protected void usingDatabase(string $database, callable $callable)

Runs the given callable using the given database.

Parameters

string $database
callable $callable

Return Value

void

protected void whenNotUsingInMemoryDatabase(callable $callback)

Apply the given callback when tests are not using in memory database.

Parameters

callable $callback

Return Value

void

protected void switchToDatabase(string $database)

Switch to the given database.

Parameters

string $database

Return Value

void

protected string testDatabase($database)

Returns the test database name.

Parameters

$database

Return Value

string

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.