/** * Converts base band to dto. * @param \MetaPlayer\Model\BaseBand $baseBand * @return BandDto */ private function convertBaseBandToDto(BaseBand $baseBand) { $dto = new BandDto(); $dto->id = $baseBand->getId(); $dto->name = $baseBand->getName(); $dto->endDate = ViewHelper::formatDate($baseBand->getEndDate()); $dto->foundDate = ViewHelper::formatDate($baseBand->getFoundDate()); return $dto; }
/** * @param \MetaPlayer\Model\BaseAlbum $album * @return AlbumDto */ private function convertBaseAlbumToDto(BaseAlbum $album) { $dto = new AlbumDto(); $dto->id = $album->getId(); $dto->releaseDate = ViewHelper::formatDate($album->getReleaseDate()); $dto->bandId = $album->getBand()->getId(); $dto->title = $album->getTitle(); return $dto; }
/** * @covers {className}::{origMethodName} * @todo Implement testSerialize(). */ public function testSerialize() { $dto = new BandDto(); $dto->id = 100500; $dto->name = "abc"; $dto->foundDate = ViewHelper::formatDate(new \DateTime()); $dto->endDate = array($dto, 'date', 'other date'); $json = $this->object->serialize($dto); $deser = $this->object->deserialize($json); $this->assertTrue($deser instanceof BandDto); $this->assertEquals($dto->id, $deser->id); $this->assertTrue($deser->endDate[0] instanceof BandDto); $this->assertEquals($dto->id, $deser->endDate[0]->id); }