Exemplo n.º 1
0
 private function givenIHaveCreatedAValidRecordForThisTable()
 {
     $generator = new FieldValuesGenerator();
     $data = $generator->getRequiredRandomRecordData($this->table->getFields());
     $this->record = $this->table->createRecord($data);
     $this->thenTheRecordShouldBeValid();
 }
Exemplo n.º 2
0
 /**
  * Sets record data
  * NOTE: setData does not change record modified state
  *
  * @param array $data
  */
 public function setData(array $data)
 {
     $fields = $this->_table->getFields();
     foreach ($fields as $fieldName => $definition) {
         if (isset($data[$fieldName])) {
             $value = $data[$fieldName];
         } else {
             if (array_key_exists($fieldName, $data)) {
                 $value = null;
             } else {
                 $value = isset($definition['default']) ? $definition['default'] : null;
             }
         }
         $this->_data[$fieldName] = $value;
         $this->handleOwningFieldRelation($fieldName, null);
     }
 }
Exemplo n.º 3
0
 /**
  * @param  Table $table
  * @param  array $defaultFieldValues
  * @return Record
  */
 protected function getRecordWithRandomData(Table $table, array $defaultFieldValues = array())
 {
     $fieldValueGenerator = new FieldValuesGenerator();
     $recordData = $fieldValueGenerator->getRandomRecordData($table->getFields(), $defaultFieldValues);
     return $table->createRecord($recordData);
 }