Class FixtureManager
A factory class to manage the life cycle of test fixtures
Property Summary
- 
        $_debug protectedboolIs the test runner being run with --debugenabled. When true, fixture SQL will also be logged.
- 
        $_fixtureMap protectedCake\Datasource\FixtureInterface[]Holds the fixture classes that where instantiated indexed by class name 
- 
        $_initialized protectedboolWas this instance already initialized? 
- 
        $_insertionMap protectedarrayA map of connection names and the fixture currently in it. 
- 
        $_loaded protectedCake\Datasource\FixtureInterface[]Holds the fixture classes that where instantiated 
- 
        $_processed protectedarrayList of TestCase class name that have been processed 
Method Summary
- 
          _aliasConnections() protectedAdd aliases for all non test prefixed connections. 
- 
          _fixtureConnections() protectedGet the unique list of connections that a set of fixtures contains. 
- 
          _initDb() protectedInitializes this class with a DataSource object to use as default for all fixtures 
- 
          _loadFixtures() protectedLooks for fixture files and instantiates the classes accordingly 
- 
          _runOperation() protectedRun a function on each connection and collection of fixtures. 
- 
          _setupTable() protectedRuns the drop and create commands on the fixtures if necessary. 
- 
          fixturize() publicInspects the test to look for unloaded fixtures and loads them 
- 
          isFixtureSetup() publicCheck whether or not a fixture has been inserted in a given connection name. 
- 
          load() publicCreates the fixtures tables and inserts data on them. 
- 
          loadSingle() publicCreates a single fixture table and loads data into it. 
- 
          loaded() publicGet the loaded fixtures. 
- 
          setDebug() publicModify the debug mode. 
- 
          shutDown() publicDrop all fixture tables loaded by this class 
- 
          unload() publicTruncates the fixtures tables 
Method Detail
_aliasConnections() ¶ protected
_aliasConnections(): voidAdd 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(string[] $fixtures): arrayGet the unique list of connections that a set of fixtures contains.
Parameters
- 
                string[]$fixtures
- The array of fixtures a list of connections is needed from. 
Returns
arrayAn array of connection names.
_initDb() ¶ protected
_initDb(): voidInitializes this class with a DataSource object to use as default for all fixtures
Returns
void_loadFixtures() ¶ protected
_loadFixtures(Cake\TestSuite\TestCase $test): voidLooks 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(string[] $fixtures, callable $operation): voidRun a function on each connection and collection of fixtures.
Parameters
- 
                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\Database\Connection $db, string[] $sources, bool $drop = true): voidRuns the drop and create commands on the fixtures if necessary.
Parameters
- 
                Cake\Datasource\FixtureInterface$fixture
- the fixture object to create 
- 
                Cake\Database\Connection$db
- The Connection object instance to use 
- 
                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): voidInspects the test to look for unloaded fixtures and loads them
Parameters
- 
                Cake\TestSuite\TestCase$test
- The test case to inspect. 
Returns
voidisFixtureSetup() ¶ public
isFixtureSetup(string $connection, Cake\Datasource\FixtureInterface $fixture): boolCheck whether or not 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): voidCreates the fixtures tables and inserts data on them.
Parameters
- 
                Cake\TestSuite\TestCase$test
- The test to inspect for fixture loading. 
Returns
voidThrows
Cake\Core\Exception\ExceptionWhen fixture records cannot be inserted.
RuntimeExceptionloadSingle() ¶ public
loadSingle(string $name, Cake\Datasource\ConnectionInterface|null $db = null, bool $dropTables = true): voidCreates a single fixture table and loads data into it.
Parameters
- 
                string$name
- of the fixture 
- 
                Cake\Datasource\ConnectionInterface|null$db optional
- Connection instance or leave null to get a Connection from the fixture 
- 
                bool$dropTables optional
- Whether or not tables should be dropped and re-created. 
Returns
voidThrows
UnexpectedValueExceptionif $name is not a previously loaded class
setDebug() ¶ public
setDebug(bool $debug): voidModify the debug mode.
Parameters
- 
                bool$debug
- Whether or not fixture debug mode is enabled. 
Returns
voidunload() ¶ public
unload(Cake\TestSuite\TestCase $test): voidTruncates 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
Cake\Datasource\FixtureInterface[]$_loaded ¶ protected
Holds the fixture classes that where instantiated
Type
Cake\Datasource\FixtureInterface[]