/** * @param array $data * * @return Genre */ public function create(array $data = array()) { $credits = new Credits(); if (array_key_exists('media', $data)) { $credits->setMedia($this->hydrate($credits->getMedia(), $data['media'])); if (array_key_exists('seasons', $data['media'])) { $episodes = $this->getTvSeasonFactory()->createCollection($data['media']['seasons']); $credits->getMedia()->setSeasons($episodes); } if (array_key_exists('episodes', $data['media'])) { $episodes = $this->getTvEpisodeFactory()->createCollection($data['media']['episodes']); $credits->getMedia()->setEpisodes($episodes); } } if (array_key_exists('person', $data)) { $credits->setPerson($this->getPeopleFactory()->create($data['person'])); } return $this->hydrate($credits, $data); }
/** * @test */ public function shouldBeFunctional() { /** * @var CreditsFactory $factory */ $factory = $this->getFactory(); $this->assertInstanceOf('Tmdb\\Model\\Credits', $this->credits); $this->assertEquals('cast', $this->credits->getCreditType()); $this->assertEquals('Actors', $this->credits->getDepartment()); $this->assertEquals('Actor', $this->credits->getJob()); $this->assertInstanceOf('Tmdb\\Model\\Credits\\Media', $this->credits->getMedia()); $this->assertEquals(5, $this->credits->getMedia()->getId()); $this->assertEquals('Seinfeld', $this->credits->getMedia()->getName()); $this->assertEquals('Seinfeld', $this->credits->getMedia()->getOriginalName()); $this->assertEquals('', $this->credits->getMedia()->getCharacter()); $this->assertEquals('tv', $this->credits->getMediaType()); $this->assertEquals('5240760b5dbf5b0c2c0139db', $this->credits->getId()); $this->assertInstanceOf('Tmdb\\Model\\Person', $this->credits->getPerson()); $this->assertEquals('Bryan Cranston', $this->credits->getPerson()->getName()); $this->assertEquals(17419, $this->credits->getPerson()->getId()); }