CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • FixtureInjector
  • FixtureManager
  • TestFixture

Class FixtureManager

A factory class to manage the life cycle of test fixtures

Namespace: Cake\TestSuite\Fixture
Location: TestSuite/Fixture/FixtureManager.php

Properties summary

  • $_debug protected
    boolean

    Is the test runner being run with --debug enabled. When true, fixture SQL will also be logged.

  • $_fixtureMap protected
    Cake\Datasource\FixtureInterface[]
    Holds the fixture classes that where instantiated indexed by class name
  • $_initialized protected
    boolean
    Was this instance already initialized?
  • $_insertionMap protected
    array
    A map of connection names and the fixture currently in it.
  • $_loaded protected
    Cake\Datasource\FixtureInterface[]
    Holds the fixture classes that where instantiated
  • $_processed protected
    array
    List of TestCase class name that have been processed

Method Summary

  • _aliasConnections() protected
    Add aliases for all non test prefixed connections.
  • _fixtureConnections() protected
    Get the unique list of connections that a set of fixtures contains.
  • _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
  • _runOperation() protected
    Run a function on each connection and collection of fixtures.
  • _setupTable() protected
    Runs the drop and create commands on the fixtures if necessary.
  • fixturize() public
    Inspects the test to look for unloaded fixtures and loads them
  • isFixtureSetup() public
    Check whether or not a fixture has been inserted in a given connection name.
  • load() public
    Creates the fixtures tables and inserts data on them.
  • loadSingle() public
    Creates a single fixture table and loads data into it.
  • loaded() public
    Get the loaded fixtures.
  • setDebug() public
    Modify the debug mode.
  • shutDown() public
    Drop all fixture tables loaded by this class
  • unload() public
    Truncates the fixtures tables

Method Detail

_aliasConnections() protected ¶

_aliasConnections( )

Add aliases for all non test prefixed connections.

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

_fixtureConnections() protected ¶

_fixtureConnections( string[] $fixtures )

Get 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
array
An array of connection names.

_initDb() protected ¶

_initDb( )

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

_loadFixtures() protected ¶

_loadFixtures( Cake\TestSuite\TestCase $test )

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.

_runOperation() protected ¶

_runOperation( string[] $fixtures , callable $operation )

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

_setupTable() protected ¶

_setupTable( Cake\Datasource\FixtureInterface $fixture , Cake\Database\Connection $db , array $sources , boolean $drop = true )

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 optional true
whether drop the fixture if it is already created or not

fixturize() public ¶

fixturize( Cake\TestSuite\TestCase $test )

Inspects the test to look for unloaded fixtures and loads them

Parameters
Cake\TestSuite\TestCase $test
The test case to inspect.

isFixtureSetup() public ¶

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

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

load() public ¶

load( Cake\TestSuite\TestCase $test )

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

loadSingle() public ¶

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

Creates a single fixture table and loads data into it.

Parameters
string $name
of the fixture
Cake\Datasource\ConnectionInterface|null $db optional null
Connection instance or leave null to get a Connection 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

loaded() public ¶

loaded( )

Get the loaded fixtures.

Returns
array

setDebug() public ¶

setDebug( boolean $debug )

Modify the debug mode.

Parameters
boolean $debug
Whether or not fixture debug mode is enabled.

shutDown() public ¶

shutDown( )

Drop all fixture tables loaded by this class

unload() public ¶

unload( Cake\TestSuite\TestCase $test )

Truncates the fixtures tables

Parameters
Cake\TestSuite\TestCase $test
The test to inspect for fixture unloading.

Properties detail

$_debug ¶

protected boolean

Is the test runner being run with --debug enabled. When true, fixture SQL will also be logged.

false

$_fixtureMap ¶

protected Cake\Datasource\FixtureInterface[]

Holds the fixture classes that where instantiated indexed by class name

[]

$_initialized ¶

protected boolean

Was this instance already initialized?

false

$_insertionMap ¶

protected array

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

[]

$_loaded ¶

protected Cake\Datasource\FixtureInterface[]

Holds the fixture classes that where instantiated

[]

$_processed ¶

protected array

List of TestCase class name that have been processed

[]
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs