private function givenIHaveCreatedAValidRecordForThisTable() { $generator = new FieldValuesGenerator(); $data = $generator->getRequiredRandomRecordData($this->table->getFields()); $this->record = $this->table->createRecord($data); $this->thenTheRecordShouldBeValid(); }
public function testRecordReturnsToBeUnmodified() { $initialData = array('username' => 'David'); $record = $this->table->createRecord($initialData); $record->set('username', 'Micheal'); $this->assertTrue($record->isModified()); $record->set('username', 'David'); $this->assertFalse($record->isModified()); }
/** * Gets record (retrieved from repository if exists, or create new record!) * * @param Table $table * @param array $data * @param bool $exists * @throws \UnexpectedValueException * @return Record */ public function getOrCreateRecord(Table $table, array $data, $exists = false) { $id = $table->getIdentifierAsString($data); if ($id !== false && $table->isInRepository($id)) { $record = $table->getFromRepository($id); } else { $record = $table->createRecord($data, $exists); } return $record; }
/** * @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); }
public function testClear() { $this->table->createRecord(array('id' => 7, 'username' => 'Bart'), true); $this->repository->clear(); $this->assertEquals(0, $this->repository->count()); }