trait InteractsWithDatabase

Methods

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

Assert that a given where condition exists in the database.

assertDatabaseMissing(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null)

Assert that a given where condition does not exist in the database.

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

Assert the count of table entries.

assertDatabaseEmpty(iterable|Model|string $table, UnitEnum|string|null $connection = null)

Assert that the given table or tables has no entries.

assertSoftDeleted(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null, string|null $deletedAtColumn = 'deleted_at')

Assert the given record has been "soft deleted".

assertNotSoftDeleted(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null, string|null $deletedAtColumn = 'deleted_at')

Assert the given record has not been "soft deleted".

assertModelExists(iterable|Model|string $model)

Assert the given model exists in the database.

assertModelMissing(iterable|Model|string $model)

Assert the given model does not exist in the database.

expectsDatabaseQueryCount(int $expected, UnitEnum|string|null $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, UnitEnum|string|null $connection = null)

Cast a JSON string to a database compatible type.

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

Get the database connection.

string
getTable(Model|string $table)

Get the table name from the given model or string.

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

Get the table connection specified in the given model.

string|null
getDeletedAtColumn(Model|string $table, string|null $defaultColumnName = 'deleted_at')

Get the table column name used for soft deletes.

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

Get the model entity from the given model or string.

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

Seed a given database connection.

Details

at line 30
protected InteractsWithDatabase assertDatabaseHas(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null)

Assert that a given where condition exists in the database.

Parameters

iterable|Model|string $table
array $data
UnitEnum|string|null $connection

Return Value

InteractsWithDatabase

at line 69
protected InteractsWithDatabase assertDatabaseMissing(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null)

Assert that a given where condition does not exist in the database.

Parameters

iterable|Model|string $table
array $data
UnitEnum|string|null $connection

Return Value

InteractsWithDatabase

at line 108
protected InteractsWithDatabase assertDatabaseCount(Model|string $table, int $count, UnitEnum|string|null $connection = null)

Assert the count of table entries.

Parameters

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

Return Value

InteractsWithDatabase

at line 123
protected InteractsWithDatabase assertDatabaseEmpty(iterable|Model|string $table, UnitEnum|string|null $connection = null)

Assert that the given table or tables has no entries.

Parameters

iterable|Model|string $table
UnitEnum|string|null $connection

Return Value

InteractsWithDatabase

at line 147
protected InteractsWithDatabase assertSoftDeleted(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null, string|null $deletedAtColumn = 'deleted_at')

Assert the given record has been "soft deleted".

Parameters

iterable|Model|string $table
array $data
UnitEnum|string|null $connection
string|null $deletedAtColumn

Return Value

InteractsWithDatabase

at line 193
protected InteractsWithDatabase assertNotSoftDeleted(iterable|Model|string $table, array $data = [], UnitEnum|string|null $connection = null, string|null $deletedAtColumn = 'deleted_at')

Assert the given record has not been "soft deleted".

Parameters

iterable|Model|string $table
array $data
UnitEnum|string|null $connection
string|null $deletedAtColumn

Return Value

InteractsWithDatabase

at line 238
protected InteractsWithDatabase assertModelExists(iterable|Model|string $model)

Assert the given model exists in the database.

Parameters

iterable|Model|string $model

Return Value

InteractsWithDatabase

at line 248
protected InteractsWithDatabase assertModelMissing(iterable|Model|string $model)

Assert the given model does not exist in the database.

Parameters

iterable|Model|string $model

Return Value

InteractsWithDatabase

at line 256
InteractsWithDatabase expectsDatabaseQueryCount(int $expected, UnitEnum|string|null $connection = null)

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

Parameters

int $expected
UnitEnum|string|null $connection

Return Value

InteractsWithDatabase

at line 284
protected bool isSoftDeletableModel(mixed $model)

Determine if the argument is a soft deletable model.

Parameters

mixed $model

Return Value

bool

at line 292
Expression castAsJson(array|object|string $value, UnitEnum|string|null $connection = null)

Cast a JSON string to a database compatible type.

Parameters

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

Return Value

Expression

at line 314
protected Connection getConnection(UnitEnum|string|null $connection = null, Model|string|null $table = null)

Get the database connection.

Parameters

UnitEnum|string|null $connection
Model|string|null $table

Return Value

Connection

at line 334
protected string getTable(Model|string $table)

Get the table name from the given model or string.

Parameters

Model|string $table

Return Value

string

at line 348
protected string|null getTableConnection(Model|string|null $table)

Get the table connection specified in the given model.

Parameters

Model|string|null $table

Return Value

string|null

at line 362
protected string|null getDeletedAtColumn(Model|string $table, string|null $defaultColumnName = 'deleted_at')

Get the table column name used for soft deletes.

Parameters

Model|string $table
string|null $defaultColumnName

Return Value

string|null

at line 372
protected Model|null newModelFor(Model|string|null $table)

Get the model entity from the given model or string.

Parameters

Model|string|null $table

Return Value

Model|null

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

Seed a given database connection.

Parameters

array|string $class

Return Value

InteractsWithDatabase