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 TestFixture

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

Namespace: Cake\TestSuite\Fixture

Property Summary

  • $_schema protected
    Cake\Database\Schema\Table

    The Cake\Database\Schema\Table for this fixture.

  • $connection public
    string

    Fixture Datasource

  • $created public
    array

    List of datasources where this fixture has been created

  • $fields public
    array

    Fields / Schema for the fixture.

  • $import public
    array

    Configuration for importing fixture schema

  • $records public
    array

    Fixture records to be inserted.

  • $table public
    string

    Full Table Name

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.

  • create() public

    Run before all tests execute, should return SQL statement to create table for this fixture could be executed successfully.

  • drop() public

    Run after all tests executed, should return SQL statement to drop table for this fixture.

  • init() public

    Initialize the fixture.

  • insert() public

    Run before each tests is executed, should return a set of SQL statements to insert records for the table of this fixture could be executed successfully.

  • schema() public

    Get/Set the Cake\Database\Schema\Table instance used by this fixture.

  • truncate() public

    Truncates the current fixture. Can be overwritten by classes extending CakeFixture to trigger other events before / after truncate.

Method Detail

__construct() ¶ public

__construct()

Instantiate the fixture.

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

_getRecords() ¶ protected

_getRecords(): array

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

Returns
array

_schemaFromFields() ¶ protected

_schemaFromFields(): void

Build the fixtures table schema from the fields property.

Returns
void

_schemaFromImport() ¶ protected

_schemaFromImport(): void

Build fixture schema from a table in another datasource.

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

create() ¶ public

create(Connection $db): bool

Run before all tests execute, should return SQL statement to create table for this fixture could be executed successfully.

Parameters
Connection $db

An instance of the database object used to create the fixture table

Returns
bool

drop() ¶ public

drop(Connection $db): bool

Run after all tests executed, should return SQL statement to drop table for this fixture.

Parameters
Connection $db

An instance of the database object used to create the fixture table

Returns
bool

init() ¶ public

init(): void

Initialize the fixture.

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

insert() ¶ public

insert(Connection $db): bool

Run before each tests is executed, should return a set of SQL statements to insert records for the table of this fixture could be executed successfully.

Parameters
Connection $db

An instance of the database into which the records will be inserted

Returns
bool

schema() ¶ public

schema(Cake\Database\Schema\Table $schema = null): void|Cake\Database\Schema\Table

Get/Set the Cake\Database\Schema\Table instance used by this fixture.

Parameters
Cake\Database\Schema\Table $schema optional

The table to set.

Returns
void|Cake\Database\Schema\Table

truncate() ¶ public

truncate(Connection $db): bool

Truncates the current fixture. Can be overwritten by classes extending CakeFixture to trigger other events before / after truncate.

Parameters
Connection $db

A reference to a db instance

Returns
bool

Property Detail

$_schema ¶ protected

The Cake\Database\Schema\Table for this fixture.

Type
Cake\Database\Schema\Table

$connection ¶ public

Fixture Datasource

Type
string

$created ¶ public

List of datasources where this fixture has been created

Type
array

$fields ¶ public

Fields / Schema for the fixture.

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

Type
array

$import ¶ public

Configuration for importing fixture schema

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

Type
array

$records ¶ public

Fixture records to be inserted.

Type
array

$table ¶ public

Full Table Name

Type
string
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