public function testSettersAndGetters() { $bookEntity = $this->bookEntityProvider->getBookEntityWithRandomData(); $this->testedObj->setTitle($bookEntity->getTitle())->setDescription($bookEntity->getDescription())->setIsbn($bookEntity->getIsbn())->setPublisher($bookEntity->getPublisher())->setYear($bookEntity->getYear()); $this->assertSame($bookEntity->getTitle(), $this->testedObj->getTitle()); $this->assertSame($bookEntity->getDescription(), $this->testedObj->getDescription()); $this->assertSame($bookEntity->getIsbn(), $this->testedObj->getIsbn()); $this->assertSame($bookEntity->getPublisher(), $this->testedObj->getPublisher()); $this->assertSame($bookEntity->getYear(), $this->testedObj->getYear()); $this->testedObj->setPrice('841,21'); $this->assertSame(841.21, $this->testedObj->getPrice()); }
/** * @param BookEntity $bookEntity * @param bool $withId * * @return array */ public function getDataFromBookEntity(BookEntity $bookEntity, $withId = true) { $data = []; if ($withId && $bookEntity->getId()) { $data['id'] = $bookEntity->getId(); } $data = ['title' => $bookEntity->getTitle(), 'description' => $bookEntity->getDescription(), 'isbn' => $bookEntity->getIsbn(), 'year' => $bookEntity->getYear(), 'publisher' => $bookEntity->getPublisher(), 'price' => $bookEntity->getPrice()]; return $data; }