Class FixtureHelper
Helper for managing fixtures.
Method Summary
-
getForeignReferences() protected
Gets array of foreign references for fixtures table.
-
insert() public
Inserts fixture data.
-
insertConnection() protected
Inserts all fixtures for a connection and provides friendly errors for bad data.
-
loadFixtures() public
Finds fixtures from their TestCase names such as 'core.Articles'.
-
runPerConnection() public
Runs the callback once per connection.
-
sortByConstraint() protected
Sort fixtures with foreign constraints last if possible, otherwise returns null.
-
truncate() public
Truncates fixture tables.
-
truncateConnection() protected
Truncates all fixtures for a connection and provides friendly errors for bad data.
Method Detail
getForeignReferences() ¶ protected
getForeignReferences(Cake\Database\Connection $connection, Cake\Datasource\FixtureInterface $fixture): array<string>
Gets array of foreign references for fixtures table.
Parameters
-
Cake\Database\Connection
$connection Database connection
-
Cake\Datasource\FixtureInterface
$fixture Database fixture
Returns
array<string>
insert() ¶ public
insert(arrayCake\Datasource\FixtureInterface> $fixtures): void
Inserts fixture data.
Parameters
-
arrayCake\Datasource\FixtureInterface>
$fixtures Test fixtures
Returns
void
insertConnection() ¶ protected
insertConnection(Cake\Datasource\ConnectionInterface $connection, arrayCake\Datasource\FixtureInterface> $fixtures): void
Inserts all fixtures for a connection and provides friendly errors for bad data.
Parameters
-
Cake\Datasource\ConnectionInterface
$connection Fixture connection
-
arrayCake\Datasource\FixtureInterface>
$fixtures Connection fixtures
Returns
void
loadFixtures() ¶ public
loadFixtures(list<string> $fixtureNames): arrayCake\Datasource\FixtureInterface>
Finds fixtures from their TestCase names such as 'core.Articles'.
Parameters
-
list<string>
$fixtureNames Fixture names from test case
Returns
arrayCake\Datasource\FixtureInterface>
runPerConnection() ¶ public
runPerConnection(Closure $callback, arrayCake\Datasource\FixtureInterface> $fixtures): void
Runs the callback once per connection.
The callback signature:
function callback(ConnectionInterface $connection, array $fixtures)
Parameters
-
Closure
$callback Callback run per connection
-
arrayCake\Datasource\FixtureInterface>
$fixtures Test fixtures
Returns
void
sortByConstraint() ¶ protected
sortByConstraint(Cake\Database\Connection $connection, arrayCake\Datasource\FixtureInterface> $fixtures): array|null
Sort fixtures with foreign constraints last if possible, otherwise returns null.
Parameters
-
Cake\Database\Connection
$connection Database connection
-
arrayCake\Datasource\FixtureInterface>
$fixtures Database fixtures
Returns
array|null
truncate() ¶ public
truncate(arrayCake\Datasource\FixtureInterface> $fixtures): void
Truncates fixture tables.
Parameters
-
arrayCake\Datasource\FixtureInterface>
$fixtures Test fixtures
Returns
void
truncateConnection() ¶ protected
truncateConnection(Cake\Datasource\ConnectionInterface $connection, arrayCake\Datasource\FixtureInterface> $fixtures): void
Truncates all fixtures for a connection and provides friendly errors for bad data.
Parameters
-
Cake\Datasource\ConnectionInterface
$connection Fixture connection
-
arrayCake\Datasource\FixtureInterface>
$fixtures Connection fixtures
Returns
void