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
Gets array of foreign references for fixtures table.
Parameters
-
Cake\Database\Connection
$connection Database connection
-
Cake\Datasource\FixtureInterface
$fixture Database fixture
Returns
array
insert() ¶ public
insert(array<Cake\Datasource\FixtureInterface> $fixtures): void
Inserts fixture data.
Parameters
-
array<Cake\Datasource\FixtureInterface>
$fixtures Test fixtures
Returns
void
insertConnection() ¶ protected
insertConnection(Cake\Datasource\ConnectionInterface $connection, array<Cake\Datasource\FixtureInterface> $fixtures): void
Inserts all fixtures for a connection and provides friendly errors for bad data.
Parameters
-
Cake\Datasource\ConnectionInterface
$connection Fixture connection
-
array<Cake\Datasource\FixtureInterface>
$fixtures Connection fixtures
Returns
void
loadFixtures() ¶ public
loadFixtures(array<string> $fixtureNames): array<Cake\Datasource\FixtureInterface>
Finds fixtures from their TestCase names such as 'core.Articles'.
Parameters
-
array<string>
$fixtureNames Fixture names from test case
Returns
array<Cake\Datasource\FixtureInterface>
runPerConnection() ¶ public
runPerConnection(Closure $callback, array<Cake\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
-
array<Cake\Datasource\FixtureInterface>
$fixtures Test fixtures
Returns
void
sortByConstraint() ¶ protected
sortByConstraint(Cake\Database\Connection $connection, array<Cake\Datasource\FixtureInterface> $fixtures): array|null
Sort fixtures with foreign constraints last if possible, otherwise returns null.
Parameters
-
Cake\Database\Connection
$connection Database connection
-
array<Cake\Datasource\FixtureInterface>
$fixtures Database fixtures
Returns
array|null
truncate() ¶ public
truncate(array<Cake\Datasource\FixtureInterface> $fixtures): void
Truncates fixture tables.
Parameters
-
array<Cake\Datasource\FixtureInterface>
$fixtures Test fixtures
Returns
void
truncateConnection() ¶ protected
truncateConnection(Cake\Datasource\ConnectionInterface $connection, array<Cake\Datasource\FixtureInterface> $fixtures): void
Truncates all fixtures for a connection and provides friendly errors for bad data.
Parameters
-
Cake\Datasource\ConnectionInterface
$connection Fixture connection
-
array<Cake\Datasource\FixtureInterface>
$fixtures Connection fixtures
Returns
void