コード例 #1
0
ファイル: DataGenerator.php プロジェクト: honeybee/trellis
 /**
  * This method fills the entity with fake data. You may customize the
  * fake data used for each attribute by using the options array.
  *
  * Supported options:
  * - OPTION_LOCALE: Locale for fake data (e.g. 'en_UK', defaults to 'de_DE').
  * - OPTION_MARK_CLEAN: Calls `$entity->markClean()` at the end to prevent
  *                 change events to occur after faking data. Default is false.
  * - OPTION_FIELD_VALUES: array of `attribute_name` => `value` pairs to customize
  *                  fake values per attribute of the given entity. You can
  *                  either specify a direct value or provide a closure. The
  *                  closure must return the value you want to set on that attribute.
  * - OPTION_EXCLUDED_FIELDS: Array of attribute_names to excluded from filling
  *                  with fake data.
  * - OPTION_GUESS_PROVIDER_BY_NAME: Boolean true by default. Certain attribute_names
  *                  trigger different providers (e.g. firstname or email).
  *
  * @param EntityInterface $entity an instance of the entity to fill with fake data.
  * @param array $options array of options to customize fake data creation.
  *
  * @return void
  *
  * @throws \Trellis\Runtime\Entity\InvalidValueException in case of fake data being invalid for the given attribute
  * @throws \Trellis\Runtime\Entity\BadValueException in case of invalid locale option string
  * @throws \Trellis\Common\Error\RuntimeException on EmbeddedEntityListAttribute misconfiguration
  */
 public static function fill(EntityInterface $entity, array $options = array())
 {
     $data_generator = new static();
     $data_generator->fake($entity, $options);
 }
コード例 #2
0
ファイル: DataGenerator.php プロジェクト: berlinonline/dat0r
 /**
  * This method fills the document with fake data. You may customize the
  * fake data used for each field by using the options array.
  *
  * Supported options:
  * - OPTION_LOCALE: Locale for fake data (e.g. 'en_UK', defaults to 'de_DE').
  * - OPTION_MARK_CLEAN: Calls `$document->markClean()` at the end to prevent
  *                 change events to occur after faking data. Default is false.
  * - OPTION_FIELD_VALUES: array of `fieldname` => `value` pairs to customize
  *                  fake values per field of the given document. You can
  *                  either specify a direct value or provide a closure. The
  *                  closure must return the value you want to set on that field.
  * - OPTION_EXCLUDED_FIELDS: Array of fieldnames to excluded from filling
  *                  with fake data.
  * - OPTION_GUESS_PROVIDER_BY_NAME: Boolean true by default. Certain fieldnames
  *                  trigger different providers (e.g. firstname or email).
  *
  * @param IDocument $document an instance of the document to fill with fake data.
  * @param array $options array of options to customize fake data creation.
  *
  * @return void
  *
  * @throws \Dat0r\Core\Document\InvalidValueException in case of fake data being invalid for the given field
  * @throws \InvalidArgumentException in case of invalid locale option string
  * @throws \Dat0r\Core\Error\LogicException on AggregateField misconfiguration
  * @throws \Dat0r\Core\Error\InvalidImplementorException on various misconfigurations
  * @throws \Dat0r\Core\Error\ObjectImmutableException if an instance is frozen (closed to modifications)
  */
 public static function fill(IDocument $document, array $options = array())
 {
     $data_generator = new static();
     $data_generator->fake($document, $options);
 }