class FixtureBlueprint (View source)

A blueprint on how to create instances of a certain DataObject subclass.

Relies on a FixtureFactory to manage database relationships between instances, and manage the mappings between fixture identifiers and their database IDs.

Properties

protected array $defaults
protected string $name
protected string $class
protected array $callbacks

Methods

public
__construct(string $name, string $class = null, array $defaults = array())

No description

public
createObject(string $identifier, array $data = null, array $fixtures = null)

No description

public
setDefaults(array $defaults)

No description

public
array
getDefaults()

No description

public
string
getClass()

No description

public
addCallback(string $type, callable $callback)

See class documentation.

public
removeCallback(string $type, callable $callback)

No description

protected
invokeCallbacks($type, $args = array())

No description

protected
string
parseValue($value, array $fixtures = null, string $class = null)

Parse a value from a fixture file. If it starts with => it will get an ID from the fixture dictionary

protected
setValue($obj, $name, $value, $fixtures = null)

No description

protected
overrideField($obj, $fieldName, $value, $fixtures = null)

No description

Details

__construct(string $name, string $class = null, array $defaults = array())

No description

Parameters

string $name
string $class

Defaults to $name

array $defaults

DataObject createObject(string $identifier, array $data = null, array $fixtures = null)

No description

Parameters

string $identifier

Unique identifier for this fixture type

array $data

Map of property names to their values.

array $fixtures

Map of fixture names to an associative array of their in-memory identifiers mapped to their database IDs. Used to look up existing fixtures which might be referenced in the $data attribute via the => notation.

Return Value

DataObject

setDefaults(array $defaults)

No description

Parameters

array $defaults

array getDefaults()

No description

Return Value

array

string getClass()

No description

Return Value

string

addCallback(string $type, callable $callback)

See class documentation.

Parameters

string $type
callable $callback

removeCallback(string $type, callable $callback)

No description

Parameters

string $type
callable $callback

protected invokeCallbacks($type, $args = array())

No description

Parameters

$type
$args

protected string parseValue($value, array $fixtures = null, string $class = null)

Parse a value from a fixture file. If it starts with => it will get an ID from the fixture dictionary

Parameters

$value
array $fixtures

See createObject()

string $class

If the value parsed is a class relation, this parameter will be given the value of that class's name

Return Value

string

Fixture database ID, or the original value

protected setValue($obj, $name, $value, $fixtures = null)

No description

Parameters

$obj
$name
$value
$fixtures

protected overrideField($obj, $fieldName, $value, $fixtures = null)

No description

Parameters

$obj
$fieldName
$value
$fixtures