\Cake\TestSuite\FixtureFixtureManager

A factory class to manage the life cycle of test fixtures

Summary

Methods
Properties
Constants
setDebug()
fixturize()
loaded()
load()
unload()
loadSingle()
shutDown()
isFixtureSetup()
No public properties found
No constants found
_aliasConnections()
_initDb()
_loadFixtures()
_setupTable()
_runOperation()
_fixtureConnections()
$_initialized
$_loaded
$_fixtureMap
$_insertionMap
$_processed
$_debug
N/A
No private methods found
No private properties found
N/A

Properties

$_initialized

$_initialized : boolean

Was this instance already initialized?

Type

boolean

$_loaded

$_loaded : array<mixed,\Cake\Datasource\FixtureInterface>

Holds the fixture classes that where instantiated

Type

array<mixed,\Cake\Datasource\FixtureInterface>

$_fixtureMap

$_fixtureMap : array<mixed,\Cake\Datasource\FixtureInterface>

Holds the fixture classes that where instantiated indexed by class name

Type

array<mixed,\Cake\Datasource\FixtureInterface>

$_insertionMap

$_insertionMap : array

A map of connection names and the fixture currently in it.

Type

array

$_processed

$_processed : array

List of TestCase class name that have been processed

Type

array

$_debug

$_debug : boolean

Is the test runner being run with `--debug` enabled.

When true, fixture SQL will also be logged.

Type

boolean

Methods

setDebug()

setDebug(boolean  $debug) : void

Modify the debug mode.

Parameters

boolean $debug

Whether or not fixture debug mode is enabled.

fixturize()

fixturize(\Cake\TestSuite\TestCase  $test) : void

Inspects the test to look for unloaded fixtures and loads them

Parameters

\Cake\TestSuite\TestCase $test

The test case to inspect.

loaded()

loaded() : array

Get the loaded fixtures.

Returns

array

load()

load(\Cake\TestSuite\TestCase  $test) : void

Creates the fixtures tables and inserts data on them.

Parameters

\Cake\TestSuite\TestCase $test

The test to inspect for fixture loading.

Throws

\Cake\Core\Exception\Exception

When fixture records cannot be inserted.

unload()

unload(\Cake\TestSuite\TestCase  $test) : void

Truncates the fixtures tables

Parameters

\Cake\TestSuite\TestCase $test

The test to inspect for fixture unloading.

loadSingle()

loadSingle(string  $name, \Cake\Datasource\ConnectionInterface|null  $db = null, boolean  $dropTables = true) : void

Creates a single fixture table and loads data into it.

Parameters

string $name

of the fixture

\Cake\Datasource\ConnectionInterface|null $db

Connection instance or leave null to get a Connection from the fixture

boolean $dropTables

Whether or not tables should be dropped and re-created.

Throws

\UnexpectedValueException

if $name is not a previously loaded class

shutDown()

shutDown() : void

Drop all fixture tables loaded by this class

isFixtureSetup()

isFixtureSetup(string  $connection, \Cake\Datasource\FixtureInterface  $fixture) : boolean

Check 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

boolean

_aliasConnections()

_aliasConnections() : void

Add aliases for all non test prefixed connections.

This allows models to use the test connections without a pile of configuration work.

_initDb()

_initDb() : void

Initializes this class with a DataSource object to use as default for all fixtures

_loadFixtures()

_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.

Throws

\UnexpectedValueException

when a referenced fixture does not exist.

_setupTable()

_setupTable(\Cake\Datasource\FixtureInterface  $fixture, \Cake\Database\Connection  $db, array  $sources, boolean  $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\Database\Connection $db

The Connection object instance to use

array $sources

The existing tables in the datasource.

boolean $drop

whether drop the fixture if it is already created or not

_runOperation()

_runOperation(array  $fixtures, callable  $operation) : void

Run a function on each connection and collection of fixtures.

Parameters

array $fixtures

A list of fixtures to operate on.

callable $operation

The operation to run on each connection + fixture set.

_fixtureConnections()

_fixtureConnections(array  $fixtures) : array

Get the unique list of connections that a set of fixtures contains.

Parameters

array $fixtures

The array of fixtures a list of connections is needed from.

Returns

array —

An array of connection names.