trait Illuminate / Foundation / Testing / Concerns / InteractsWithDatabase
You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

InteractsWithDatabase

Methods

protected

assertDatabaseHas ( $table , array $data , $connection ) : $this

Assert that a given where condition exists in the database.

Parameters

  • $table Model |string
  • $data array
  • $connection string|null
protected

assertDatabaseMissing ( $table , array $data , $connection ) : $this

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

Parameters

  • $table Model |string
  • $data array
  • $connection string|null
protected

assertDatabaseCount ( $table , int $count , $connection ) : $this

Assert the count of table entries.

Parameters

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

assertDatabaseEmpty ( $table , $connection ) : $this

Assert that the given table has no entries.

Parameters

  • $table Model |string
  • $connection string|null
protected

assertSoftDeleted ( $table , array $data , $connection , $deletedAtColumn ) : $this

Assert the given record has been "soft deleted".

Parameters

  • $table Model |string
  • $data array
  • $connection string|null
  • $deletedAtColumn string|null
protected

assertNotSoftDeleted ( $table , array $data , $connection , $deletedAtColumn ) : $this

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

Parameters

  • $table Model |string
  • $data array
  • $connection string|null
  • $deletedAtColumn string|null
protected

assertModelExists ( $model ) : $this

Assert the given model exists in the database.

Parameters

protected

assertModelMissing ( $model ) : $this

Assert the given model does not exist in the database.

Parameters

public

expectsDatabaseQueryCount ( $expected , $connection ) : $this

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

Parameters

  • $expected int
  • $connection string|null
protected

isSoftDeletableModel ( $model ) : bool

Determine if the argument is a soft deletable model.

Parameters

  • $model mixed
public

castAsJson ( $value ) : Expression

Cast a JSON string to a database compatible type.

Parameters

  • $value array|object|string
protected

getConnection ( $connection , $table ) : Connection

Get the database connection.

Parameters

  • $connection string|null
  • $table string|null
protected

getTable ( $table ) : string

Get the table name from the given model or string.

Parameters

protected

getTableConnection ( $table ) : string|null

Get the table connection specified in the given model.

Parameters

protected

getDeletedAtColumn ( $table , $defaultColumnName ) : string

Get the table column name used for soft deletes.

Parameters

  • $table string
  • $defaultColumnName string
protected

newModelFor ( $table ) : Model |null

Get the model entity from the given model or string.

Parameters

public

seed ( $class ) : $this

Seed a given database connection.

Parameters

  • $class array|string