public function testThatEmptyFieldsBecomeNull() { $book = new Book(['id' => '', 'author_id' => '1234', 'title' => 'Lorem ipsum', 'isdn' => '', 'date_published' => '']); $this->assertNull($book->getId()); $this->assertNull($book->getIsbn()); $this->assertNull($book->getDatePublished()); }
/** * Update a record in the database * * @param Book $book * @return boolean */ protected function update(Book $book) { $sql = 'UPDATE book SET author_id =:author_id, title = :title, isbn = :isbn, date_published = :date_published WHERE id = :id'; $params = ['author_id' => $book->getAuthorId(), 'title' => $book->getTitle(), 'isbn' => $book->getIsbn(), 'date_published' => $book->getDatePublished(), 'id' => $book->getId()]; $statement = $this->dbAdapter->prepare($sql); return $statement->execute($params); }