CompositeIncrementsFixture
extends TestFixture
in package
Cake TestFixture is responsible for building and destroying tables to be used during testing.
Table of Contents
Properties
- $connection : string
- Fixture Datasource
- $fields : array<string|int, mixed>
- fields property
- $import : array<string|int, mixed>|null
- Configuration for importing fixture schema
- $records : array<string|int, mixed>
- records property
- $table : string
- Full Table Name
- $_constraints : array<string, mixed>
- Fixture constraints to be created.
- $_schema : TableSchemaInterface|SqlGeneratorInterface
- The schema for this fixture.
- $_tableLocator : LocatorInterface|null
- Table locator instance
- $defaultTable : string|null
- This object's default table alias.
Methods
- __construct() : mixed
- Instantiate the fixture.
- connection() : string
- Get the connection name this fixture should be inserted into.
- create() : bool
- Create the fixture schema/mapping/definition
- createConstraints() : bool
- Build and execute SQL queries necessary to create the constraints for the fixture
- drop() : bool
- Run after all tests executed, should remove the table/collection from the connection.
- dropConstraints() : bool
- Build and execute SQL queries necessary to drop the constraints for the fixture
- fetchTable() : Table
- Convenience method to get a table instance.
- getTableLocator() : LocatorInterface
- Gets the table locator.
- getTableSchema() : TableSchemaInterface|SqlGeneratorInterface
- Get and set the schema for this fixture.
- init() : void
- Initialize the fixture.
- insert() : StatementInterface|bool
- Run before each test is executed.
- setTableLocator() : $this
- Sets the table locator.
- setTableSchema() : $this
- Get and set the schema for this fixture.
- sourceName() : string
- Get the table/collection name for this fixture.
- truncate() : bool
- Truncates the current fixture.
- _getRecords() : array<string|int, mixed>
- Converts the internal records into data used to generate a query.
- _schemaFromFields() : void
- Build the fixtures table schema from the fields property.
- _schemaFromImport() : void
- Build fixture schema from a table in another datasource.
- _schemaFromReflection() : void
- Build fixture schema directly from the datasource
- _tableFromClass() : string
- Returns the table name using the fixture class
Properties
$connection
Fixture Datasource
public
string
$connection
= 'test'
$fields
fields property
public
array<string|int, mixed>
$fields
= ['id' => ['type' => 'integer', 'null' => false, 'autoIncrement' => true], 'account_id' => ['type' => 'integer', 'null' => false], 'name' => ['type' => 'string', 'default' => null], '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id', 'account_id']]]]
$import
Configuration for importing fixture schema
public
array<string|int, mixed>|null
$import
Accepts a connection
and model
or table
key, to define
which table and which connection contain the schema to be
imported.
$records
records property
public
array<string|int, mixed>
$records
= []
$table
Full Table Name
public
string
$table
Tags
$_constraints
Fixture constraints to be created.
protected
array<string, mixed>
$_constraints
= []
$_schema
The schema for this fixture.
protected
TableSchemaInterface|SqlGeneratorInterface
$_schema
Tags
$_tableLocator
Table locator instance
protected
LocatorInterface|null
$_tableLocator
$defaultTable
This object's default table alias.
protected
string|null
$defaultTable
= null
Methods
__construct()
Instantiate the fixture.
public
__construct() : mixed
Tags
connection()
Get the connection name this fixture should be inserted into.
public
connection() : string
Tags
Return values
stringcreate()
Create the fixture schema/mapping/definition
public
create(ConnectionInterface $connection) : bool
Parameters
- $connection : ConnectionInterface
-
An instance of the connection the fixture should be created on.
Tags
Return values
bool —True on success, false on failure.
createConstraints()
Build and execute SQL queries necessary to create the constraints for the fixture
public
createConstraints(ConnectionInterface $connection) : bool
Parameters
- $connection : ConnectionInterface
-
An instance of the database into which the constraints will be created.
Tags
Return values
bool —on success or if there are no constraints to create, or false on failure
drop()
Run after all tests executed, should remove the table/collection from the connection.
public
drop(ConnectionInterface $connection) : bool
Parameters
- $connection : ConnectionInterface
-
An instance of the connection the fixture should be removed from.
Tags
Return values
bool —True on success, false on failure.
dropConstraints()
Build and execute SQL queries necessary to drop the constraints for the fixture
public
dropConstraints(ConnectionInterface $connection) : bool
Parameters
- $connection : ConnectionInterface
-
An instance of the database into which the constraints will be dropped.
Tags
Return values
bool —on success or if there are no constraints to drop, or false on failure
fetchTable()
Convenience method to get a table instance.
public
fetchTable([string|null $alias = null ][, array<string, mixed> $options = [] ]) : Table
Parameters
- $alias : string|null = null
-
The alias name you want to get. Should be in CamelCase format. If
null
then the value of $defaultTable property is used. - $options : array<string, mixed> = []
-
The options you want to build the table with. If a table has already been loaded the registry options will be ignored.
Tags
Return values
TablegetTableLocator()
Gets the table locator.
public
getTableLocator() : LocatorInterface
Return values
LocatorInterfacegetTableSchema()
Get and set the schema for this fixture.
public
getTableSchema() : TableSchemaInterface|SqlGeneratorInterface
Tags
Return values
TableSchemaInterface|SqlGeneratorInterfaceinit()
Initialize the fixture.
public
init() : void
Tags
insert()
Run before each test is executed.
public
insert(ConnectionInterface $connection) : StatementInterface|bool
Parameters
- $connection : ConnectionInterface
-
An instance of the connection into which the records will be inserted.
Tags
Return values
StatementInterface|bool —on success or if there are no records to insert, or false on failure.
setTableLocator()
Sets the table locator.
public
setTableLocator(LocatorInterface $tableLocator) : $this
Parameters
- $tableLocator : LocatorInterface
-
LocatorInterface instance.
Return values
$thissetTableSchema()
Get and set the schema for this fixture.
public
setTableSchema(mixed $schema) : $this
Parameters
- $schema : mixed
-
The table to set.
Tags
Return values
$thissourceName()
Get the table/collection name for this fixture.
public
sourceName() : string
Tags
Return values
stringtruncate()
Truncates the current fixture.
public
truncate(ConnectionInterface $connection) : bool
Parameters
- $connection : ConnectionInterface
-
A reference to a db instance
Tags
Return values
bool_getRecords()
Converts the internal records into data used to generate a query.
protected
_getRecords() : array<string|int, mixed>
Return values
array<string|int, mixed>_schemaFromFields()
Build the fixtures table schema from the fields property.
protected
_schemaFromFields() : void
_schemaFromImport()
Build fixture schema from a table in another datasource.
protected
_schemaFromImport() : void
Tags
_schemaFromReflection()
Build fixture schema directly from the datasource
protected
_schemaFromReflection() : void
Tags
_tableFromClass()
Returns the table name using the fixture class
protected
_tableFromClass() : string