/**
  * @param AbstractModel $object
  */
 public function save(AbstractModel $object)
 {
     $record = $this->entityMapper->objectToRecord($object);
     if ($record['id']) {
         $where = ['id' => (int) $record['id']];
         $this->db->update($this->tablename, $record, $where);
     } else {
         $insertId = $this->db->insert($this->tablename, $record);
         $object->setId($insertId);
     }
 }
 /**
  * @test
  */
 public function objectToRecord()
 {
     $id = 42;
     $timestamp = 1413182967;
     $title = '1kcfRvy6J1WsWtXvgOu/kXba';
     $object = new EntityTestItem();
     $object->setTitle($title);
     $parentObject = new EntityTestItem();
     $parentObject->setId($id);
     $object->setParent($parentObject);
     $date = new \DateTime();
     $date->setTimestamp($timestamp);
     $object->setDate($date);
     $record = $this->entityMapper->objectToRecord($object);
     $this->assertSame((string) $timestamp, $record['date']);
     $this->assertSame((string) $id, $record['parent']);
     $this->assertSame($title, $record['title']);
 }