trait InteractsWithDatabase

Methods

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

Details

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

Assert that a given where condition exists in the database.

Parameters

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

Return Value

$this

at line 70
protected $this assertDatabaseMissing(Model>|Model|Model>|string $table, array $data = [], null|string $connection = null)

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

Parameters

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

Return Value

$this

at line 111
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

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

Assert that the given table or tables has no entries.

Parameters

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

Return Value

$this

at line 155
protected $this assertSoftDeleted(Model>|Model|Model>|Model|string>|string $table, array $data = [], null|string $connection = null, null|string $deletedAtColumn = 'deleted_at')

Assert the given record has been "soft deleted".

Parameters

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

Return Value

$this

at line 203
protected $this assertNotSoftDeleted(Model>|Model|Model>|Model|string>|string $table, array $data = [], null|string $connection = null, null|string $deletedAtColumn = 'deleted_at')

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

Parameters

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

Return Value

$this

at line 248
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

at line 259
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

at line 271
$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

at line 302
protected bool isSoftDeletableModel(mixed $model)

Determine if the argument is a soft deletable model.

Parameters

mixed $model

Return Value

bool

at line 314
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

at line 338
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

at line 359
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

at line 374
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

at line 390
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

at line 401
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

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

Seed a given database connection.

Parameters

array|string $class

Return Value

InteractsWithDatabase