Fr3nch13/CakePHP Utilities

FixtureManager
in package

A factory class to manage the life cycle of test fixtures

Table of Contents

Properties

$_debug  : bool
Is the test runner being run with `--debug` enabled.
$_fixtureMap  : array<string|int, FixtureInterface>
Holds the fixture classes that where instantiated indexed by class name
$_initialized  : bool
Was this instance already initialized?
$_insertionMap  : array<string, array<string|int, FixtureInterface>>
A map of connection names and the fixture currently in it.
$_loaded  : array<string|int, FixtureInterface>
Holds the fixture classes that where instantiated
$_processed  : array<string, bool>
List of TestCase class name that have been processed

Methods

fixturize()  : void
getInserted()  : array<string|int, string>
isFixtureSetup()  : bool
Check whether a fixture has been inserted in a given connection name.
load()  : void
loaded()  : array<string|int, FixtureInterface>
loadSingle()  : void
setDebug()  : void
Modify the debug mode.
shutDown()  : void
Drop all fixture tables loaded by this class
unload()  : void
Truncates the fixtures tables
_aliasConnections()  : void
Add aliases for all non test prefixed connections.
_fixtureConnections()  : array<string|int, mixed>
Get the unique list of connections that a set of fixtures contains.
_initDb()  : void
Initializes this class with a DataSource object to use as default for all fixtures
_loadFixtures()  : void
Looks for fixture files and instantiates the classes accordingly
_runOperation()  : void
Run a function on each connection and collection of fixtures.
_setupTable()  : void
Runs the drop and create commands on the fixtures if necessary.

Properties

$_debug

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

protected bool $_debug = false

When true, fixture SQL will also be logged.

$_fixtureMap

Holds the fixture classes that where instantiated indexed by class name

protected array<string|int, FixtureInterface> $_fixtureMap = []

$_initialized

Was this instance already initialized?

protected bool $_initialized = false

$_insertionMap

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

protected array<string, array<string|int, FixtureInterface>> $_insertionMap = []

$_processed

List of TestCase class name that have been processed

protected array<string, bool> $_processed = []

Methods

getInserted()

public getInserted() : array<string|int, string>
Return values
array<string|int, string>

isFixtureSetup()

Check whether a fixture has been inserted in a given connection name.

public isFixtureSetup(string $connection, FixtureInterface $fixture) : bool
Parameters
$connection : string

The connection name.

$fixture : FixtureInterface

The fixture to check.

Return values
bool

loadSingle()

public loadSingle(string $name[, ConnectionInterface|null $connection = null ][, bool $dropTables = true ]) : void
Parameters
$name : string

Name

$connection : ConnectionInterface|null = null

Connection

$dropTables : bool = true

Drop all tables prior to loading schema files

Tags
throws
UnexpectedValueException

setDebug()

Modify the debug mode.

public setDebug(bool $debug) : void
Parameters
$debug : bool

Whether fixture debug mode is enabled.

shutDown()

Drop all fixture tables loaded by this class

public shutDown() : void

unload()

Truncates the fixtures tables

public unload(TestCase $test) : void
Parameters
$test : TestCase

The test to inspect for fixture unloading.

_aliasConnections()

Add aliases for all non test prefixed connections.

protected _aliasConnections() : void

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

_fixtureConnections()

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

protected _fixtureConnections(array<string|int, string> $fixtures) : array<string|int, mixed>
Parameters
$fixtures : array<string|int, string>

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

Return values
array<string|int, mixed>

An array of connection names.

_initDb()

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

protected _initDb() : void

_loadFixtures()

Looks for fixture files and instantiates the classes accordingly

protected _loadFixtures(TestCase $test) : void
Parameters
$test : TestCase

The test suite to load fixtures for.

Tags
throws
UnexpectedValueException

when a referenced fixture does not exist.

_runOperation()

Run a function on each connection and collection of fixtures.

protected _runOperation(array<string|int, string> $fixtures, callable $operation) : void
Parameters
$fixtures : array<string|int, string>

A list of fixtures to operate on.

$operation : callable

The operation to run on each connection + fixture set.

_setupTable()

Runs the drop and create commands on the fixtures if necessary.

protected _setupTable(FixtureInterface $fixture, ConnectionInterface $db, array<string|int, string> $sources[, bool $drop = true ]) : void
Parameters
$fixture : FixtureInterface

the fixture object to create

$db : ConnectionInterface

The Connection object instance to use

$sources : array<string|int, string>

The existing tables in the datasource.

$drop : bool = true

whether drop the fixture if it is already created or not


        
On this page

Search results