FixtureFactory
class FixtureFactory (View source)
Manages a set of database fixtures for DataObject records as well as raw database table rows.
Delegates creation of objects to 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 dependent.
Properties
| protected | array | $fixtures | ||
| protected | FixtureBlueprint[] | $blueprints | 
Methods
Writes the fixture into the database using DataObjects
Writes the fixture into the database directly using a database manipulation.
Return all of the IDs in the fixture of a particular class name.
Remove all fixtures previously defined through createObject() or createRaw(), both from the internal fixture mapping and the database.
Parse a value from a fixture file. If it starts with => it will get an ID from the fixture dictionary
Details
        
                            $this
    define(string $name, array|FixtureBlueprint $defaults = [])
        
    
    No description
        
                            DataObject
    createObject(string $name, string $identifier, array $data = null)
        
    
    Writes the fixture into the database using DataObjects
        
                            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.
        
                            int|false
    getId(string $class, string $identifier)
        
    
    Get the ID of an object from the fixture.
        
                            array|false
    getIds(string $class)
        
    
    Return all of the IDs in the fixture of a particular class name.
        
                            $this
    setId(string $class, string $identifier, int $databaseId)
        
    
    No description
        
                            T|null
    get(T> $class, string $identifier)
        
    
    Get an object from the fixture.
        
                            array
    getFixtures()
        
    
    No description
        
                            
    clear(string $limitToClass = null, bool $metadata = false)
        
    
    Remove all fixtures previously defined through createObject() or createRaw(), both from the internal fixture mapping and the database.
If the $class argument is set, limit clearing to items of this class.
        
                            array
    getBlueprints()
        
    
    No description
        
                            FixtureBlueprint|false
    getBlueprint(string $name)
        
    
    No description
        
                    protected        string
    parseValue(string $value)
        
    
    Parse a value from a fixture file. If it starts with => it will get an ID from the fixture dictionary