FixtureFactory
class FixtureFactory
Manages a set of database fixtures for {@link DataObject} records as well as raw database table rows.
Delegates creation of objects to {@link FixtureBlueprint}, which can implement class- and use-case specific fixture setup.
Supports referencing model relations through a specialized syntax:
$factory = new FixtureFactory();
$relatedObj = $factory->createObject(
'MyRelatedClass',
'relation1'
);
$obj = $factory->createObject(
'MyClass',
'object1'
array('MyRelationName' => '=>MyRelatedClass.relation1')
);
Relation loading is order dependant.
Methods
Writes the fixture into the database using DataObjects
Writes the fixture into the database directly using a database manipulation.
Get the ID of an object from the fixture.
Return all of the IDs in the fixture of a particular class name.
No description
Get an object from the fixture.
No description
Remove all fixtures previously defined through {@link createObject()} or {@link createRaw()}, both from the internal fixture mapping and the database.
No description
No description
Details
at line 44
define(String $name, array|FixtureBlueprint $defaults = array())
at line 66
DataObject
createObject(String $name, String $identifier, Array $data = null)
Writes the fixture into the database using DataObjects
at line 91
Int
createRaw(String $table, String $identifier, Array $data)
Writes the fixture into the database directly using a database manipulation.
Does not use blueprints. Only supports tables with a primary key.
at line 109
getId($class, $identifier)
Get the ID of an object from the fixture.
at line 122
A
getIds($class)
Return all of the IDs in the fixture of a particular class name.
at line 135
setId(String $class, String $identifier, Int $databaseId)
at line 146
get($class, $identifier)
Get an object from the fixture.
at line 155
Array
getFixtures()
at line 166
clear($limitToClass = null)
Remove all fixtures previously defined through {@link createObject()} or {@link createRaw()}, both from the internal fixture mapping and the database.
If the $class argument is set, limit clearing to items of this class.