Class CakeFixtureManager

A factory class to manage the life cycle of test fixtures

Package: Cake\TestSuite\Fixture
Copyright: Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
License: MIT License
Location: Cake/TestSuite/Fixture/CakeFixtureManager.php

Properties summary

  • $_db protected
    Default datasource to use
  • $_fixtureMap protected
    array
    Holds the fixture classes that where instantiated indexed by class name
  • $_initialized protected
    boolean
    Was this class already initialized?
  • $_loaded protected
    array
    Holds the fixture classes that where instantiated

Method Summary

  • _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
  • Parse the fixture path included in test cases, to get the fixture class name, and the real fixture path including sub-directories

  • _setupTable() protected
    Runs the drop, create and truncate commands on the fixtures if necessary.
  • fixturize() public
    Inspects the test to look for unloaded fixtures and loads them
  • load() public
    Creates the fixtures tables and inserts data on them.
  • loadSingle() public
    Creates a single fixture table and loads data into it.
  • shutDown() public
    Drop all fixture tables loaded by this class
  • unload() public
    Truncates 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

UnexpectedValueException
when 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

array
containing 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

UnexpectedValueException
if $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

$_dbsource

protected DataSource

Default datasource to use

null

$_fixtureMapsource

protected array

Holds the fixture classes that where instantiated indexed by class name

array()

$_initializedsource

protected boolean

Was this class already initialized?

false

$_loadedsource

protected array

Holds the fixture classes that where instantiated

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