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 bool $withRandomId * * @return BookEntity */ public function getBookEntityWithRandomData($withRandomId = true) { $bookEntity = new BookEntity(); $bookEntity->setTitle(uniqid('title'))->setDescription(uniqid('description'))->setPublisher(uniqid('publisher'))->setYear(mt_rand(1900, date('Y')))->setPrice(mt_rand(1, 10000) / 100)->setIsbn($this->getIsbn13Random()); if ($withRandomId) { Bootstrap::setIdToEntity($bookEntity, mt_rand(1, 999)); } return $bookEntity; }