CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.0 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.0
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 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

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
    • Log
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
      • Fixture
      • Stub
    • Utility
    • Validation
    • View

Class FixtureManager

A factory class to manage the life cycle of test fixtures

Namespace: Cake\TestSuite\Fixture

Property Summary

  • $_fixtureMap protected
    array

    Holds the fixture classes that where instantiated indexed by class name

  • $_initialized protected
    bool

    Was this class already initialized?

  • $_loaded protected
    array

    Holds the fixture classes that where instantiated

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

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

  • shutDown() public

    Drop all fixture tables loaded by this class

  • unload() public

    Truncates the fixtures tables

Method Detail

_aliasConnections() ¶ protected

_aliasConnections(): void

Add aliases for all non test prefixed connections.

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

Returns
void

_fixtureConnections() ¶ protected

_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

_initDb() ¶ protected

_initDb(): void

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

Returns
void

_loadFixtures() ¶ protected

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

Returns
void
Throws
UnexpectedValueException
when a referenced fixture does not exist.

_runOperation() ¶ protected

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

Returns
void

_setupTable() ¶ protected

_setupTable(Cake\TestSuite\Fixture\TestFixture $fixture, Connection $db, array $sources, bool $drop = true): void

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

Parameters
Cake\TestSuite\Fixture\TestFixture $fixture

the fixture object to create

Connection $db

the datasource instance to use

array $sources

The existing tables in the datasource.

bool $drop optional

whether drop the fixture if it is already created or not

Returns
void

fixturize() ¶ public

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.

Returns
void

load() ¶ public

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.

Returns
void
Throws
Cake\Core\Exception\Exception
When fixture records cannot be inserted.

loadSingle() ¶ public

loadSingle(string $name, Cake\Database\Connection $db = null, bool $dropTables = true): void

Creates a single fixture table and loads data into it.

Parameters
string $name

of the fixture

Cake\Database\Connection $db optional

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

bool $dropTables optional

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

Returns
void
Throws
UnexpectedValueException
if $name is not a previously loaded class

loaded() ¶ public

loaded(): array

Get the loaded fixtures.

Returns
array

shutDown() ¶ public

shutDown(): void

Drop all fixture tables loaded by this class

Returns
void

unload() ¶ public

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

Truncates the fixtures tables

Parameters
Cake\TestSuite\TestCase $test

The test to inspect for fixture unloading.

Returns
void

Property Detail

$_fixtureMap ¶ protected

Holds the fixture classes that where instantiated indexed by class name

Type
array

$_initialized ¶ protected

Was this class already initialized?

Type
bool

$_loaded ¶ protected

Holds the fixture classes that where instantiated

Type
array
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs