Class TestFixture
Cake TestFixture is responsible for building and destroying tables to be used during testing.
- Cake\TestSuite\Fixture\TestFixture implements Cake\Datasource\FixtureInterface
Method Detail
__constructsource public
__construct( )
Instantiate the fixture.
Throws
Cake\Core\Exception\Exception
on invalid datasource usage.
_getRecordssource protected
_getRecords( )
Converts the internal records into data used to generate a query.
Returns
array
array
_schemaFromFieldssource protected
_schemaFromFields( )
Build the fixtures table schema from the fields property.
_schemaFromImportsource protected
_schemaFromImport( )
Build fixture schema from a table in another datasource.
Throws
Cake\Core\Exception\Exception
when trying to import from an empty table.
connectionsource public
connection( )
Get the connection name this fixture should be inserted into.
Returns
string
string
Implementation of
Cake\Datasource\FixtureInterface::connection()
createsource public
create( Cake\Datasource\ConnectionInterface $db )
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.
Implementation of
Cake\Datasource\FixtureInterface::create()
createConstraintssource public
createConstraints( Cake\Datasource\ConnectionInterface $db )
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
Implementation of
Cake\Datasource\FixtureInterface::createConstraints()
dropsource public
drop( Cake\Datasource\ConnectionInterface $db )
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.
Implementation of
Cake\Datasource\FixtureInterface::drop()
dropConstraintssource public
dropConstraints( Cake\Datasource\ConnectionInterface $db )
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
Implementation of
Cake\Datasource\FixtureInterface::dropConstraints()
initsource public
init( )
Initialize the fixture.
Throws
Cake\ORM\Exception\MissingTableClassException
When importing from a table that does not exist.
insertsource public
insert( Cake\Datasource\ConnectionInterface $db )
Run before each test is executed.
Parameters
-
Cake\Datasource\ConnectionInterface
$db
- An instance of the connection into which the records will be inserted.
Returns
boolean
on success or if there are no records to insert, or false on failure.
Implementation of
Cake\Datasource\FixtureInterface::insert()
schemasource public
schema( Cake\Database\Schema\Table $schema null )
Get/Set the Cake\Database\Schema\Table instance used by this fixture.
Parameters
-
Cake\Database\Schema\Table
$schema
optional null - The table to set.
Returns
Cake\Database\Schema\Table|null
\Cake\Database\Schema\Table|null
sourceNamesource public
sourceName( )
Get the table/collection name for this fixture.
Returns
string
string
Implementation of
Cake\Datasource\FixtureInterface::sourceName()
truncatesource public
truncate( Cake\Datasource\ConnectionInterface $db )
Truncates the current fixture.
Parameters
-
Cake\Datasource\ConnectionInterface
$db
- A reference to a db instance
Returns
boolean
bool
Implementation of
Cake\Datasource\FixtureInterface::truncate()
Properties summary
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.TestSuite.Fixture.TestFixture.html