SilverStripe 3.0 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
Version: master
  • master
  • 3.1
  • 3.0
  • 2.4
  • tagfield

Packages

  • cms
    • assets
    • batchaction
    • batchactions
    • content
    • control
    • controller
    • controllers
    • core
    • export
    • filesystem
    • forms
    • model
    • publishers
    • reports
    • search
    • security
    • tasks
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • framework
    • admin
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • fields-relational
    • filesystem
    • formatters
    • forms
    • gridfield
    • i18n
    • injector
    • integration
    • manifest
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • validation
    • view
  • None
  • PHP

Classes

  • _DiffEngine
  • _DiffOp
  • _DiffOp_Add
  • _DiffOp_Change
  • _DiffOp_Copy
  • _DiffOp_Delete
  • Aggregate
  • Aggregate_Relationship
  • ClassInfo
  • CSSContentParser
  • Diff
  • Extension
  • FixtureBlueprint
  • FixtureFactory
  • GenericTemplateGlobalProvider
  • MappedDiff
  • Object
  • SS_Cache
  • SSViewer_BasicIteratorSupport
  • TokenisedRegularExpression
  • ValidationResult
  • YamlFixture

Interfaces

  • TemplateGlobalProvider
  • TemplateIteratorProvider

Functions

  • _t
  • get_increase_memory_limit_max
  • get_increase_time_limit_max
  • getClassFile
  • getSysTempDir
  • increase_memory_limit_to
  • increase_time_limit_to
  • increase_xdebug_nesting_level_to
  • project
  • set_increase_memory_limit_max
  • set_increase_time_limit_max
  • singleton
  • stripslashes_recursively
  • translate_memstring

Class FixtureFactory

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 dependant.

Package: framework\core
Located at sapphire/dev/FixtureFactory.php

Methods summary

public
# define( String $name, array|FixtureBlueprint $defaults = array() )

Parameters

$name
String
$name Unique name for this blueprint
$defaults
array|FixtureBlueprint
$defaults Array of default values, or a blueprint instance
public DataObject
# createObject( String $name, String $identifier, Array $data = null )

Writes the fixture into the database using DataObjects

Writes the fixture into the database using DataObjects

Parameters

$name
String
$name Name of the FixtureBlueprint to use, usually a DataObject subclass.
$identifier
String
$identifier Unique identifier for this fixture type
$data
Array
$data Map of properties. Overrides default data.

Returns

DataObject
public 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.

Writes the fixture into the database directly using a database manipulation. Does not use blueprints. Only supports tables with a primary key.

Parameters

$table
String
$table Existing database table name
$identifier
String
$identifier Unique identifier for this fixture type
$data
Array
$data Map of properties

Returns

Int
Database identifier
public
# getId( mixed $class, mixed $identifier )

Get the ID of an object from the fixture.

Get the ID of an object from the fixture.

Parameters

$class
mixed
$className The data class, as specified in your fixture file. Parent classes won't work
$identifier
mixed
$identifier The identifier string, as provided in your fixture file
public A
# getIds( mixed $class )

Return all of the IDs in the fixture of a particular class name.

Return all of the IDs in the fixture of a particular class name.

Returns

A
map of fixture-identifier => object-id
public
# setId( String $class, String $identifier, Int $databaseId )

Parameters

$class
String
$identifier
String
$identifier
$databaseId
Int
$databaseId
public
# get( mixed $class, mixed $identifier )

Get an object from the fixture.

Get an object from the fixture.

Parameters

$class
mixed
$class The data class, as specified in your fixture file. Parent classes won't work
$identifier
mixed
$identifier The identifier string, as provided in your fixture file
public Array
# getFixtures( )

Returns

Array
Map of class names, containing a map of in-memory identifiers mapped to database identifiers.
public
# clear( String $limitToClass = null )

Remove all fixtures previously defined through FixtureFactory::createObject() or FixtureFactory::createRaw(), both from the internal fixture mapping and the database. If the $class argument is set, limit clearing to items of this class.

Remove all fixtures previously defined through FixtureFactory::createObject() or FixtureFactory::createRaw(), both from the internal fixture mapping and the database. If the $class argument is set, limit clearing to items of this class.

Parameters

$limitToClass
String
$class
public Array
# getBlueprints( )

Returns

Array
Of FixtureBlueprint instances
public FixtureBlueprint
# getBlueprint( String $name )

Parameters

$name
String
$name

Returns

FixtureBlueprint
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

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

Parameters

$value
String
$fieldVal

Returns

String
Fixture database ID, or the original value

Magic methods summary

Properties summary

protected array $fixtures
#

Array of fixture items, keyed by class and unique identifier, with values being the generated database ID. Does not store object instances.

Array of fixture items, keyed by class and unique identifier, with values being the generated database ID. Does not store object instances.

protected array $blueprints
#

Callbacks

Callbacks

Comments

Comment policy: Please use comments for tips and corrections about the described functionality. Comments are moderated, we reserve the right to remove comments that are inappropriate or are no longer relevant.
Use the Silverstripe Forum to ask questions.
blog comments powered by Disqus
SilverStripe 3.0 API Docs API documentation generated by ApiGen 2.8.0