On this page
Class FixtureManager
A factory class to manage the life cycle of test fixtures
Property Summary
-
$_debug protected
boolIs the test runner being run with
--debugenabled. When true, fixture SQL will also be logged. -
$_fixtureMap protected
arrayCake\Datasource\FixtureInterface>Holds the fixture classes that where instantiated indexed by class name
-
$_initialized protected
boolWas this instance already initialized?
-
$_insertionMap protected
array<string, arrayCake\Datasource\FixtureInterface>>A map of connection names and the fixture currently in it.
-
$_loaded protected
arrayCake\Datasource\FixtureInterface>Holds the fixture classes that where instantiated
-
$_processed protected
array<string, bool>List of TestCase class name that have been processed
Method Summary
_aliasConnections() protected
Add aliases for all non test prefixed connections.
_fixtureConnections() protected
Get the unique list of connections that a set of fixtures contains.
_initDb() protected
Initializes this class with a DataSource object to use as default for all fixtures
_loadFixtures() protected
Looks for fixture files and instantiates the classes accordingly
_runOperation() protected
Run a function on each connection and collection of fixtures.
_setupTable() protected
Runs the drop and create commands on the fixtures if necessary.
fixturize() public
getInserted() public
isFixtureSetup() public
Check whether a fixture has been inserted in a given connection name.
load() public
loadSingle() public
loaded() public
setDebug() public
Modify the debug mode.
shutDown() public
Drop all fixture tables loaded by this class
unload() public
Truncates the fixtures tables
Method Detail
_aliasConnections() protected
_aliasConnections(): void
Add aliases for all non test prefixed connections.
This allows models to use the test connections without a pile of configuration work.
Returns
void_fixtureConnections() protected
_fixtureConnections(array<string> $fixtures): array
Get the unique list of connections that a set of fixtures contains.
Parameters
array<string>$fixtures-
The array of fixtures a list of connections is needed from.
Returns
array_initDb() protected
_initDb(): void
Initializes this class with a DataSource object to use as default for all fixtures
Returns
void_loadFixtures() protected
_loadFixtures(Cake\TestSuite\TestCase $test): void
Looks for fixture files and instantiates the classes accordingly
Parameters
Cake\TestSuite\TestCase$test-
The test suite to load fixtures for.
Returns
voidThrows
UnexpectedValueExceptionwhen a referenced fixture does not exist.
_runOperation() protected
_runOperation(array<string> $fixtures, callable $operation): void
Run a function on each connection and collection of fixtures.
Parameters
array<string>$fixtures-
A list of fixtures to operate on.
callable$operation-
The operation to run on each connection + fixture set.
Returns
void_setupTable() protected
_setupTable(Cake\Datasource\FixtureInterface $fixture, Cake\Datasource\ConnectionInterface $db, array<string> $sources, bool $drop = true): void
Runs the drop and create commands on the fixtures if necessary.
Parameters
Cake\Datasource\FixtureInterface$fixture-
the fixture object to create
Cake\Datasource\ConnectionInterface$db-
The Connection object instance to use
array<string>$sources-
The existing tables in the datasource.
bool$drop optional-
whether drop the fixture if it is already created or not
Returns
voidfixturize() public
fixturize(Cake\TestSuite\TestCase $test): void
Parameters
Cake\TestSuite\TestCase$test-
Test case
Returns
voidgetInserted() public
getInserted(): array<string>
Returns
array<string>isFixtureSetup() public
isFixtureSetup(string $connection, Cake\Datasource\FixtureInterface $fixture): bool
Check whether a fixture has been inserted in a given connection name.
Parameters
string$connection-
The connection name.
Cake\Datasource\FixtureInterface$fixture-
The fixture to check.
Returns
boolload() public
load(Cake\TestSuite\TestCase $test): void
Parameters
Cake\TestSuite\TestCase$test-
Test case
Returns
voidThrows
RuntimeExceptionloadSingle() public
loadSingle(string $name, Cake\Datasource\ConnectionInterface|null $connection = null, bool $dropTables = true): void
Parameters
string$name-
Name
Cake\Datasource\ConnectionInterface|null$connection optional-
Connection
bool$dropTables optional-
Drop all tables prior to loading schema files
Returns
voidThrows
UnexpectedValueExceptionloaded() public
loaded(): Cake\Datasource\FixtureInterface[]
Returns
Cake\Datasource\FixtureInterface[]setDebug() public
setDebug(bool $debug): void
Modify the debug mode.
Parameters
bool$debug-
Whether fixture debug mode is enabled.
Returns
voidshutDown() public
shutDown(): void
Drop all fixture tables loaded by this class
Returns
voidunload() public
unload(Cake\TestSuite\TestCase $test): void
Truncates the fixtures tables
Parameters
Cake\TestSuite\TestCase$test-
The test to inspect for fixture unloading.
Returns
voidProperty Detail
$_debug protected
Is the test runner being run with --debug enabled. When true, fixture SQL will also be logged.
Type
bool$_fixtureMap protected
Holds the fixture classes that where instantiated indexed by class name
Type
arrayCake\Datasource\FixtureInterface>$_initialized protected
Was this instance already initialized?
Type
bool$_insertionMap protected
A map of connection names and the fixture currently in it.
Type
array<string, arrayCake\Datasource\FixtureInterface>>$_loaded protected
Holds the fixture classes that where instantiated
Type
arrayCake\Datasource\FixtureInterface>$_processed protected
List of TestCase class name that have been processed
Type
array<string, bool>© 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.4/class-Cake.TestSuite.Fixture.FixtureManager.html