\CodeIgniter\TestCIDatabaseTestCase

CIDatabaseTestCase

Summary

Methods
Properties
Constants
loadDependencies()
tearDown()
seed()
dontSeeInDatabase()
seeInDatabase()
grabFromDatabase()
hasInDatabase()
seeNumRecords()
No public properties found
No constants found
setUp()
$refresh
$seed
$basePath
$namespace
$DBGroup
$db
$migrations
$seeder
$insertCache
N/A
No private methods found
No private properties found
N/A

Properties

$refresh

$refresh : boolean

Should the db be refreshed before each test?

Type

boolean

$seed

$seed : string

The name of the fixture used for all tests within this test case.

Type

string

$basePath

$basePath : string

The path to where we can find the seeds directory.

Allows overriding the default application directories.

Type

string

$namespace

$namespace : string

The namespace to help us find the migration classes.

Type

string

$DBGroup

$DBGroup : string

The name of the database group to connect to.

If not present, will use the defaultGroup.

Type

string

$migrations

$migrations : \CodeIgniter\Database\MigrationRunner|mixed

Migration Runner instance.

Type

\CodeIgniter\Database\MigrationRunner|mixed

$insertCache

$insertCache : array

Stores information needed to remove any rows inserted via $this->hasInDatabase();

Type

array

Methods

loadDependencies()

loadDependencies() 

Load any database test dependencies.

tearDown()

tearDown() 

Takes care of any required cleanup after the test, like removing any rows inserted via $this->hasInDatabase()

seed()

seed(string  $name) 

Seeds that database with a specific seeder.

Parameters

string $name

dontSeeInDatabase()

dontSeeInDatabase(string  $table, array  $where) : boolean

Asserts that records that match the conditions in $where do not exist in the database.

Parameters

string $table
array $where

Returns

boolean

seeInDatabase()

seeInDatabase(string  $table, array  $where) : boolean

Asserts that records that match the conditions in $where DO exist in the database.

Parameters

string $table
array $where

Throws

\CodeIgniter\Database\Exceptions\DatabaseException

Returns

boolean

grabFromDatabase()

grabFromDatabase(string  $table, string  $column, array  $where) : boolean

Fetches a single column from a database row with criteria matching $where.

Parameters

string $table
string $column
array $where

Throws

\CodeIgniter\Database\Exceptions\DatabaseException

Returns

boolean

hasInDatabase()

hasInDatabase(string  $table, array  $data) : boolean

Inserts a row into to the database. This row will be removed after the test has run.

Parameters

string $table
array $data

Returns

boolean

seeNumRecords()

seeNumRecords(integer  $expected, string  $table, array  $where) : boolean

Asserts that the number of rows in the database that match $where is equal to $expected.

Parameters

integer $expected
string $table
array $where

Throws

\CodeIgniter\Database\Exceptions\DatabaseException

Returns

boolean

setUp()

setUp() 

Ensures that the database is cleaned up to a known state before each test runs.

Throws

\CodeIgniter\Exceptions\ConfigException