Cake TestFixture is responsible for building and destroying tables to be used during testing.
array
Fixture constraints to be created.
\Cake\Database\Schema\TableSchemaInterface&\Cake\Database\Schema\SqlGeneratorInterface
The schema for this fixture.
\Cake\ORM\Locator\LocatorInterface|null
Table locator instance
string
Fixture Datasource
array
Fields / Schema for the fixture.
array|null
Configuration for importing fixture schema
array
Fixture records to be inserted.
string
Full Table Name
Build and execute SQL queries necessary to create the constraints for the fixture
Build and execute SQL queries necessary to drop the constraints for the fixture
__construct()
Instantiate the fixture.
Cake\Core\Exception\Exception
_getRecords()
Converts the internal records into data used to generate a query.
array
_schemaFromFields()
Build the fixtures table schema from the fields property.
_schemaFromImport()
Build fixture schema from a table in another datasource.
Cake\Core\Exception\Exception
_schemaFromReflection()
Build fixture schema directly from the datasource
Cake\Core\Exception\Exception
_tableFromClass()
Returns the table name using the fixture class
string
connection()
Get the connection name this fixture should be inserted into.
string
create(\Cake\Datasource\ConnectionInterface $db)
Create the fixture schema/mapping/definition
\Cake\Datasource\ConnectionInterface
$db An instance of the connection the fixture should be created on.
bool
True on success, false on failure.
createConstraints(\Cake\Datasource\ConnectionInterface $db)
Build and execute SQL queries necessary to create the constraints for the fixture
\Cake\Datasource\ConnectionInterface
$db An instance of the database into which the constraints will be created.
bool
on success or if there are no constraints to create, or false on failure
drop(\Cake\Datasource\ConnectionInterface $db)
Run after all tests executed, should remove the table/collection from the connection.
\Cake\Datasource\ConnectionInterface
$db An instance of the connection the fixture should be removed from.
bool
True on success, false on failure.
dropConstraints(\Cake\Datasource\ConnectionInterface $db)
Build and execute SQL queries necessary to drop the constraints for the fixture
\Cake\Datasource\ConnectionInterface
$db An instance of the database into which the constraints will be dropped.
bool
on success or if there are no constraints to drop, or false on failure
getTableLocator()
Gets the table locator.
\Cake\ORM\Locator\LocatorInterface
getTableSchema()
Get and set the schema for this fixture.
\Cake\Database\Schema\TableSchemaInterface&\Cake\Database\Schema\SqlGeneratorInterface
init()
Initialize the fixture.
Cake\ORM\Exception\MissingTableClassException
insert(\Cake\Datasource\ConnectionInterface $db)
Run before each test is executed.
Should insert all the records into the test database.
\Cake\Datasource\ConnectionInterface
$db An instance of the connection into which the records will be inserted.
\Cake\Database\StatementInterface|bool
on success or if there are no records to insert, or false on failure.
setTableLocator(\Cake\ORM\Locator\LocatorInterface $tableLocator)
Sets the table locator.
\Cake\ORM\Locator\LocatorInterface
$tableLocator LocatorInterface instance.
$this
setTableSchema(mixed $schema)
Get and set the schema for this fixture.
\Cake\Database\Schema\TableSchemaInterface&\Cake\Database\Schema\SqlGeneratorInterface
$schema The table to set.
$this
sourceName()
Get the table/collection name for this fixture.
string
truncate(\Cake\Datasource\ConnectionInterface $db)
Truncates the current fixture.
\Cake\Datasource\ConnectionInterface
$db A reference to a db instance
bool
Fixture constraints to be created.
array
The schema for this fixture.
\Cake\Database\Schema\TableSchemaInterface&\Cake\Database\Schema\SqlGeneratorInterface
Table locator instance
\Cake\ORM\Locator\LocatorInterface|null
Fixture Datasource
string
Fields / Schema for the fixture.
This array should be compatible with Cake\Database\Schema\Schema. The _constraints
, _options
and _indexes
keys are reserved for defining constraints, options and indexes respectively.
array
Configuration for importing fixture schema
Accepts a connection
and model
or table
key, to define which table and which connection contain the schema to be imported.
array|null
Fixture records to be inserted.
array
Full Table Name
string
© 2005–present 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.
https://api.cakephp.org/4.1/class-Cake.TestSuite.Fixture.TestFixture.html