Beispiel #1
0
 public function create($title, $content, $userId)
 {
     $note = new Note();
     $note->setTitle($title);
     $note->setContent($content);
     $note->setUserId($userId);
     return $this->mapper->insert($note);
 }
 public function testUpdate()
 {
     // create a new note that should be updated
     $note = new Note();
     $note->setTitle('old_title');
     $note->setContent('old_content');
     $note->setUserId($this->userId);
     $id = $this->mapper->insert($note)->getId();
     // fromRow does not set the fields as updated
     $updatedNote = Note::fromRow(['id' => $id, 'user_id' => $this->userId]);
     $updatedNote->setContent('content');
     $updatedNote->setTitle('title');
     $result = $this->controller->update($id, 'title', 'content');
     $this->assertEquals($updatedNote, $result->getData());
     // clean up
     $this->mapper->delete($result->getData());
 }