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.7 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.7
      • 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 TestFixture

Cake TestFixture is responsible for building and destroying tables to be used during testing.

Cake\TestSuite\Fixture\TestFixture implements Cake\Datasource\FixtureInterface, Cake\Datasource\TableSchemaInterface, Cake\Database\Schema\TableSchemaAwareInterface uses Cake\ORM\Locator\LocatorAwareTrait
Namespace: Cake\TestSuite\Fixture
Location: TestSuite/Fixture/TestFixture.php

Properties summary

  • $_constraints protected
    array
    Fixture constraints to be created.
  • $_schema protected
    Cake\Database\Schema\TableSchema
    The schema for this fixture.
  • $connection public
    string
    Fixture Datasource
  • $fields public
    array
    Fields / Schema for the fixture.
  • $import public
    array|null
    Configuration for importing fixture schema
  • $records public
    array
    Fixture records to be inserted.
  • $table public
    string
    Full Table Name

Inherited Properties

  • _tableLocator

Method Summary

  • __construct() public
    Instantiate the fixture.
  • _getRecords() protected
    Converts the internal records into data used to generate a query.
  • _schemaFromFields() protected
    Build the fixtures table schema from the fields property.
  • _schemaFromImport() protected
    Build fixture schema from a table in another datasource.
  • _schemaFromReflection() protected
    Build fixture schema directly from the datasource
  • _tableFromClass() protected
    Returns the table name using the fixture class
  • connection() public
    Get the connection name this fixture should be inserted into.
  • create() public
    Create the fixture schema/mapping/definition
  • createConstraints() public

    Build and execute SQL queries necessary to create the constraints for the fixture

  • drop() public
    Run after all tests executed, should remove the table/collection from the connection.
  • dropConstraints() public

    Build and execute SQL queries necessary to drop the constraints for the fixture

  • getTableSchema() public
    Get and set the schema for this fixture.
  • init() public
    Initialize the fixture.
  • insert() public
    Run before each test is executed.
  • schema() public
    Gets/Sets the TableSchema instance used by this fixture.
  • setTableSchema() public
    Get and set the schema for this fixture.
  • sourceName() public
    Get the table/collection name for this fixture.
  • truncate() public
    Truncates the current fixture.

Method Detail

__construct() public ¶

__construct( )

Instantiate the fixture.

Throws
Cake\Core\Exception\Exception
on invalid datasource usage.

_getRecords() protected ¶

_getRecords( )

Converts the internal records into data used to generate a query.

Returns
array

_schemaFromFields() protected ¶

_schemaFromFields( )

Build the fixtures table schema from the fields property.

_schemaFromImport() protected ¶

_schemaFromImport( )

Build fixture schema from a table in another datasource.

Throws
Cake\Core\Exception\Exception
when trying to import from an empty table.

_schemaFromReflection() protected ¶

_schemaFromReflection( )

Build fixture schema directly from the datasource

Throws
Cake\Core\Exception\Exception
when trying to reflect a table that does not exist

_tableFromClass() protected ¶

_tableFromClass( )

Returns the table name using the fixture class

Returns
string

connection() public ¶

connection( )

Get the connection name this fixture should be inserted into.

Returns
string
Implementation of
Cake\Datasource\FixtureInterface::connection()

create() public ¶

create( Cake\Datasource\ConnectionInterface $db )

Create the fixture schema/mapping/definition

Parameters
Cake\Datasource\ConnectionInterface $db
An instance of the connection the fixture should be created on.
Returns
boolean
True on success, false on failure.
Implementation of
Cake\Datasource\FixtureInterface::create()

createConstraints() public ¶

createConstraints( Cake\Datasource\ConnectionInterface $db )

Build and execute SQL queries necessary to create the constraints for the fixture

Parameters
Cake\Datasource\ConnectionInterface $db
An instance of the database into which the constraints will be created
Returns
boolean
on success or if there are no constraints to create, or false on failure
Implementation of
Cake\Datasource\FixtureInterface::createConstraints()

drop() public ¶

drop( Cake\Datasource\ConnectionInterface $db )

Run after all tests executed, should remove the table/collection from the connection.

Parameters
Cake\Datasource\ConnectionInterface $db
An instance of the connection the fixture should be removed from.
Returns
boolean
True on success, false on failure.
Implementation of
Cake\Datasource\FixtureInterface::drop()

dropConstraints() public ¶

dropConstraints( Cake\Datasource\ConnectionInterface $db )

Build and execute SQL queries necessary to drop the constraints for the fixture

Parameters
Cake\Datasource\ConnectionInterface $db
An instance of the database into which the constraints will be dropped
Returns
boolean
on success or if there are no constraints to drop, or false on failure
Implementation of
Cake\Datasource\FixtureInterface::dropConstraints()

getTableSchema() public ¶

getTableSchema( )

Get and set the schema for this fixture.

Returns
Cake\Database\Schema\TableSchemaInterface|null
Implementation of
Cake\Database\Schema\TableSchemaAwareInterface::getTableSchema()

init() public ¶

init( )

Initialize the fixture.

Throws
Cake\ORM\Exception\MissingTableClassException
When importing from a table that does not exist.

insert() public ¶

insert( Cake\Datasource\ConnectionInterface $db )

Run before each test is executed.

Parameters
Cake\Datasource\ConnectionInterface $db
An instance of the connection into which the records will be inserted.
Returns
Cake\Database\StatementInterface|boolean
on success or if there are no records to insert, or false on failure.
Implementation of
Cake\Datasource\FixtureInterface::insert()

schema() public ¶

schema( Cake\Database\Schema\TableSchema $schema null )

Gets/Sets the TableSchema instance used by this fixture.

Deprecated
3.5.0 Use getTableSchema/setTableSchema instead.
Parameters
Cake\Database\Schema\TableSchema $schema optional null
The table to set.
Returns
Cake\Database\Schema\TableSchema|null
Implementation of
Cake\Datasource\TableSchemaInterface::schema()

setTableSchema() public ¶

setTableSchema( Cake\Database\Schema\TableSchemaInterface $schema )

Get and set the schema for this fixture.

Parameters
Cake\Database\Schema\TableSchemaInterface $schema
The table to set.
Returns

$this
Implementation of
Cake\Database\Schema\TableSchemaAwareInterface::setTableSchema()

sourceName() public ¶

sourceName( )

Get the table/collection name for this fixture.

Returns
string
Implementation of
Cake\Datasource\FixtureInterface::sourceName()

truncate() public ¶

truncate( Cake\Datasource\ConnectionInterface $db )

Truncates the current fixture.

Parameters
Cake\Datasource\ConnectionInterface $db
A reference to a db instance
Returns
boolean
Implementation of
Cake\Datasource\FixtureInterface::truncate()

Methods used from Cake\ORM\Locator\LocatorAwareTrait

getTableLocator() public ¶

getTableLocator( )

Gets the table locator.

Returns
Cake\ORM\Locator\LocatorInterface

setTableLocator() public ¶

setTableLocator( Cake\ORM\Locator\LocatorInterface $tableLocator )

Sets the table locator.

Parameters
Cake\ORM\Locator\LocatorInterface $tableLocator
LocatorInterface instance.
Returns

$this

tableLocator() public ¶

tableLocator( Cake\ORM\Locator\LocatorInterface $tableLocator null )

Sets the table locator. If no parameters are passed, it will return the currently used locator.

Deprecated
3.5.0 Use getTableLocator()/setTableLocator() instead.
Parameters
Cake\ORM\Locator\LocatorInterface $tableLocator optional null
LocatorInterface instance.
Returns
Cake\ORM\Locator\LocatorInterface

Magic methods inherited from Cake\Datasource\TableSchemaInterface

getTableSchema()

Properties detail

$_constraints ¶

protected array

Fixture constraints to be created.

[]

$_schema ¶

protected Cake\Database\Schema\TableSchema

The schema for this fixture.

$connection ¶

public string

Fixture Datasource

'test'

$fields ¶

public array

Fields / Schema for the fixture.

This array should be compatible with Cake\Database\Schema\Schema. The _constraints, _options and _indexes keys are reserved for defining constraints, options and indexes respectively.

[]

$import ¶

public array|null

Configuration for importing fixture schema

Accepts a connection and model or table key, to define which table and which connection contain the schema to be imported.

$records ¶

public array

Fixture records to be inserted.

[]

$table ¶

public string

Full Table Name

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