\Cake\DatasourceFixtureInterface

Defines the interface that testing fixtures use.

Summary

Methods
Constants
create()
drop()
insert()
createConstraints()
dropConstraints()
truncate()
connection()
sourceName()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

create()

create(\Cake\Datasource\ConnectionInterface  $db) : boolean

Create the fixture schema/mapping/definition

Parameters

\Cake\Datasource\ConnectionInterface $db

An instance of the connection the fixture should be created on.

Returns

boolean —

True on success, false on failure.

drop()

drop(\Cake\Datasource\ConnectionInterface  $db) : boolean

Run after all tests executed, should remove the table/collection from the connection.

Parameters

\Cake\Datasource\ConnectionInterface $db

An instance of the connection the fixture should be removed from.

Returns

boolean —

True on success, false on failure.

insert()

insert(\Cake\Datasource\ConnectionInterface  $db) : \Cake\Database\StatementInterface|boolean

Run before each test is executed.

Should insert all the records into the test database.

Parameters

\Cake\Datasource\ConnectionInterface $db

An instance of the connection into which the records will be inserted.

Returns

\Cake\Database\StatementInterface|boolean —

on success or if there are no records to insert, or false on failure.

createConstraints()

createConstraints(\Cake\Datasource\ConnectionInterface  $db) : boolean

Build and execute SQL queries necessary to create the constraints for the fixture

Parameters

\Cake\Datasource\ConnectionInterface $db

An instance of the database into which the constraints will be created

Returns

boolean —

on success or if there are no constraints to create, or false on failure

dropConstraints()

dropConstraints(\Cake\Datasource\ConnectionInterface  $db) : boolean

Build and execute SQL queries necessary to drop the constraints for the fixture

Parameters

\Cake\Datasource\ConnectionInterface $db

An instance of the database into which the constraints will be dropped

Returns

boolean —

on success or if there are no constraints to drop, or false on failure

truncate()

truncate(\Cake\Datasource\ConnectionInterface  $db) : boolean

Truncates the current fixture.

Parameters

\Cake\Datasource\ConnectionInterface $db

A reference to a db instance

Returns

boolean

connection()

connection() : string

Get the connection name this fixture should be inserted into.

Returns

string

sourceName()

sourceName() : string

Get the table/collection name for this fixture.

Returns

string