/** * {@inheritdoc} */ public function create(array $data = array()) { if (!$data) { return null; } $tvEpisode = new Episode(); if (array_key_exists('credits', $data)) { if (array_key_exists('cast', $data['credits'])) { $tvEpisode->getCredits()->setCast($this->getCastFactory()->createCollection($data['credits']['cast'], new CastMember())); } if (array_key_exists('crew', $data['credits'])) { $tvEpisode->getCredits()->setCrew($this->getCrewFactory()->createCollection($data['credits']['crew'], new CrewMember())); } } /** External ids */ if (array_key_exists('external_ids', $data)) { $tvEpisode->setExternalIds($this->hydrate(new ExternalIds(), $data['external_ids'])); } /** Images */ if (array_key_exists('images', $data)) { $tvEpisode->setImages($this->getImageFactory()->createCollectionFromTvEpisode($data['images'])); } if (array_key_exists('still_path', $data)) { $tvEpisode->setStillImage($this->getImageFactory()->createFromPath($data['still_path'], 'still_path')); } if (array_key_exists('videos', $data)) { $tvEpisode->setVideos($this->getVideoFactory()->createCollection($data['videos'])); } if (array_key_exists('changes', $data)) { $tvEpisode->setChanges($this->getChangesFactory()->createCollection($data['changes'])); } return $this->hydrate($tvEpisode, $data); }
/** * @test */ public function shouldBeAbleToOverrideDefaultCollections() { $episode = new Episode(); $class = new \stdClass(); $episode->setCredits($class); $this->assertInstanceOf('stdClass', $episode->getCredits()); }
/** * @test */ public function shouldBeFunctional() { $this->assertEquals(new \DateTime('2009-03-08'), $this->episode->getAirDate()); $this->assertEquals(1, $this->episode->getEpisodeNumber()); $this->assertEquals('Seven Thirty-Seven', $this->episode->getName()); $this->assertEquals('Walt and Jesse try to figure a way out of their partnership with Tuco. Hank tries to mend the fences between Marie and Skyler.', $this->episode->getOverview()); $this->assertEquals(62092, $this->episode->getId()); $this->assertEquals(null, $this->episode->getProductionCode()); $this->assertEquals(2, $this->episode->getSeasonNumber()); $this->assertEquals('/bwgioLAgihPCUK21rLWocDaDM3g.jpg', $this->episode->getStillPath()); $this->assertEquals(0, $this->episode->getVoteAverage()); $this->assertEquals(0, $this->episode->getVoteCount()); }
/** * @test */ public function shouldGetVideos() { $repository = $this->getRepositoryWithMockedHttpClient(); $tv = new Tv(); $tv->setId(self::TV_ID); $season = new Season(); $season->setId(self::SEASON_ID); $episode = new Episode(); $episode->setId(self::EPISODE_ID); $repository->getVideos($tv, $season, $episode); }
/** * @param FixtureEpisodeData $f * @param Tv\Episode $e * @param Tv $s */ private function writeLookupSuccessEpisode(FixtureEpisodeData $f, Tv\Episode $e, Tv $s) { try { $fileSize = $f->getFile()->getSizeHuman(); } catch (\RuntimeException $e) { $fileSize = 'UNKNOWN'; $this->io()->warning(sprintf('An error occured while retrieving the file size for %s', $f->getFile()->getPathname())); } $country = ''; $countrySet = $s->getOriginCountry(); if ($countrySet->count() > 0) { $countryKey = $countrySet->getKeys()[0]; $country = $countrySet->get($countryKey)->getIso31661(); } $rows = [['Tvdb Id', $s->getId() . '/' . $e->getId()], ['File Path', $f->getFile()->getPathname()], ['Show Name', $s->getName()], ['Season', $e->getSeasonNumber()], ['Episode Number', $e->getEpisodeNumber()], ['Episode Title', $e->getName()], ['Origin Country', $country], ['Air Date', $e->getAirDate()->format('Y\\-m\\-d')], ['Size', $fileSize], ['API Match', sprintf('<fg=green>OKAY: %d/%d</>', $s->getId(), $e->getId())]]; $this->ioVerbose(function (StyleInterface $style) use($rows) { $style->table($rows, []); }); $rows = [['File Path', $f->getFile()->getPathname()], ['Show Name', $s->getName()], ['Season/Episode', sprintf('%d/%d', $e->getSeasonNumber(), $e->getEpisodeNumber())], ['Episode Title', $e->getName()], ['Size', $fileSize], ['API Match', sprintf('<fg=green>OKAY: %d/%d</>', $s->getId(), $e->getId())]]; $this->ioNotVerbose(function (StyleInterface $style) use($rows) { $style->table($rows, []); }); }
/** * @test */ public function shouldGetVideos() { $repository = $this->getRepositoryWithMockedHttpAdapter(); $this->getAdapter()->expects($this->once())->method('get')->with($this->getRequest('tv/' . self::TV_ID . '/season/' . self::SEASON_ID . '/episode/' . self::EPISODE_ID . '/videos')); $tv = new Tv(); $tv->setId(self::TV_ID); $season = new Season(); $season->setId(self::SEASON_ID); $episode = new Episode(); $episode->setId(self::EPISODE_ID); $repository->getVideos($tv, $season, $episode); }