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 = [])

No description

public
getFactory()

No description

public
setFactory(FixtureFactory $factory)

No description

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

No description

public
$this
setDefaults(array $defaults)

No description

public
array
getDefaults()

No description

public
string
getClass()

No description

public
$this
addCallback(string $type, callable $callback)

See class documentation.

public
$this
removeCallback(string $type, callable $callback)

No description

protected
invokeCallbacks($type, $args = [])

No description

protected
string
parseValue(string $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 = [])

No description

Parameters

string $name
string $class

Defaults to $name

array $defaults

FixtureFactory getFactory()

No description

Return Value

FixtureFactory

FixtureBlueprint setFactory(FixtureFactory $factory)

No description

Parameters

FixtureFactory $factory

Return Value

FixtureBlueprint

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

Exceptions

Exception

$this setDefaults(array $defaults)

No description

Parameters

array $defaults

Return Value

$this

array getDefaults()

No description

Return Value

array

string getClass()

No description

Return Value

string

$this addCallback(string $type, callable $callback)

See class documentation.

Parameters

string $type
callable $callback

Return Value

$this

$this removeCallback(string $type, callable $callback)

No description

Parameters

string $type
callable $callback

Return Value

$this

protected invokeCallbacks($type, $args = [])

No description

Parameters

$type
$args

protected string parseValue(string $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

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