\MockDataBuilder
This class creates a process that generates mock data records. It accepts an assortment of options to customise its output.
- Author: Uncle Cheese <unclecheese@leftandmain.com>
Synopsis
class MockDataBuilder
extends Object
{
- // members
- protected array $log = ;
- protected $subjectClass;
- protected DataObject $parentObj;
- protected $parentIdentifier;
- protected string $parentField = "ParentID";
- protected integer $count = 10;
- protected bool $onlyEmpty = true;
- protected integer $relationCreateLimit = 5;
- protected bool $downloadImages = true;
- protected bool $includeRelations = true;
- protected bool $isSiteTree = false;
- // methods
- public MockDataBuilder __construct()
- public array generate()
- public void populate()
- protected void determineParentObj()
- public MockDataBuilder setParentObj()
- public void setParentField()
- public void setParentIdentifier()
- public void setCount()
- public void setOnlyEmpty()
- public void setRelationCreateLimit()
- public void setDownloadImages()
- public void setIncludeRelations()
- protected void log()
Hierarchy
Extends
- Object
Members
protected
- $count — int
- $downloadImages — bool
- $includeRelations — bool
- $isSiteTree — bool
- $log — array
- $onlyEmpty — bool
- $parentField — string
- $parentIdentifier — mixed
- $parentObj — DataObject
- $relationCreateLimit — int
- $subjectClass — string
Methods
protected
- determineParentObj() — Given a {@link $parentIdentifier} value, figure out what the parent record is.
- log() — Logs a message. Either output to console or store internally
public
- __construct() — Constructor.
- generate() — Generates new records for the subject class
- populate() — Populates existing records with mock data
- setCount() — Sets the number of records to create
- setDownloadImages() — If set to true, download images from the web to populate file relatiosn
- setIncludeRelations() — If set to true, populate has_many and many_many relations
- setOnlyEmpty() — If set to true, only populate fields that are empty
- setParentField() — Sets the foreign key field for the created records, e.g. "MyPageHolderID"
- setParentIdentifier() — Sets the parent identifier for the parent record. Could be a numeric ID or URLSegment
- setParentObj() — Sets the parent object that will own the created mock records
- setRelationCreateLimit() — Sets the foreign key field for the created records, e.g. "MyPageHolderID"