On this page
Class CakeFixtureManager
A factory class to manage the life cycle of test fixtures
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/TestSuite/Fixture/CakeFixtureManager.php
Properties summary
-
Default datasource to use
$_db
protected -
$_fixtureMap
protectedarray
-
$_initialized
protectedboolean
-
$_loaded
protectedarray
Method Summary
-
_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
-
_parseFixturePath() protected
Parse the fixture path included in test cases, to get the fixture class name, and the real fixture path including sub-directories
-
_setupTable() protectedRuns the drop, create and truncate commands on the fixtures if necessary.
-
fixturize() publicInspects the test to look for unloaded fixtures and loads them
-
load() publicCreates the fixtures tables and inserts data on them.
-
loadSingle() publicCreates a single fixture table and loads data into it.
-
shutDown() publicDrop all fixture tables loaded by this class
-
unload() publicTruncates the fixtures tables
Method Detail
_initDb()source protected
_initDb( )
Initializes this class with a DataSource object to use as default for all fixtures
_loadFixtures()source protected
_loadFixtures( array $fixtures )
Looks for fixture files and instantiates the classes accordingly
Parameters
-
array
$fixtures
- the fixture names to load using the notation {type}.{name}
Throws
UnexpectedValueExceptionwhen a referenced fixture does not exist.
_parseFixturePath()source protected
_parseFixturePath( string $fixturePath )
Parse the fixture path included in test cases, to get the fixture class name, and the real fixture path including sub-directories
Parameters
-
string
$fixturePath
- the fixture path to parse
Returns
arraycontaining fixture class name and optional additional path
_setupTable()source protected
_setupTable( CakeTestFixture $fixture , DataSource $db null , boolean $drop true )
Runs the drop, create and truncate commands on the fixtures if necessary.
Parameters
CakeTestFixture
$fixture
- the fixture object to create
DataSource
$db
optional null- the datasource instance to use
-
boolean
$drop
optional true - whether drop the fixture if it is already created or not
fixturize()source public
fixturize( CakeTestCase $test )
Inspects the test to look for unloaded fixtures and loads them
Parameters
CakeTestCase
$test
- the test case to inspect
load()source public
load( CakeTestCase $test )
Creates the fixtures tables and inserts data on them.
Parameters
CakeTestCase
$test
- the test to inspect for fixture loading
loadSingle()source public
loadSingle( string $name , DataSource $db null , boolean $dropTables true )
Creates a single fixture table and loads data into it.
Parameters
-
string
$name
- of the fixture
DataSource
$db
optional null- DataSource instance or leave null to get DataSource from the fixture
-
boolean
$dropTables
optional true - Whether or not tables should be dropped and re-created.
Throws
UnexpectedValueExceptionif $name is not a previously loaded class
shutDown()source public
shutDown( )
Drop all fixture tables loaded by this class
This will also close the session, as failing to do so will cause fatal errors with database sessions.
unload()source public
unload( CakeTestCase $test )
Truncates the fixtures tables
Parameters
CakeTestCase
$test
- the test to inspect for fixture unloading
Properties detail
$_fixtureMapsource
protected array
Holds the fixture classes that where instantiated indexed by class name
array()
© 2005–2017 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/2.10/class-CakeFixtureManager.html