/** * Tests if an Episode gets instantiated correctly using XML data * * @return void */ public function testIfEpisodeSetupCorrectly() { $xmlData = '<?xml version="1.0" encoding="UTF-8" ?> <Episode> <id>332179</id> <DVD_chapter>2</DVD_chapter> <DVD_discid>1</DVD_discid> <DVD_episodenumber>2</DVD_episodenumber> <DVD_season>3</DVD_season> <Director>|Joseph McGinty Nichol|</Director> <EpisodeName>Chuck Versus the World</EpisodeName> <EpisodeNumber>1</EpisodeNumber> <FirstAired>2007-09-24</FirstAired> <GuestStars>|Julia Ling|Vik Sahay|Mieko Hillman|</GuestStars> <IMDB_ID>123</IMDB_ID> <Language>English</Language> <Overview>Chuck Bartowski is an average computer geek...</Overview> <ProductionCode>12</ProductionCode> <Rating>9.0</Rating> <RatingCount>10</RatingCount> <SeasonNumber>1</SeasonNumber> <Writer>|Josh Schwartz|Chris Fedak|</Writer> <absolute_number>1</absolute_number> <airsafter_season>1</airsafter_season> <airsbefore_episode>2</airsbefore_episode> <airsbefore_season>3</airsbefore_season> <filename>episodes/80348-332179.jpg</filename> <lastupdated>1201292806</lastupdated> <seasonid>27985</seasonid> <seriesid>80348</seriesid> </Episode>'; $data = XmlParser::getXml($xmlData); $this->episode = new Episode($data); $this->assertEquals(332179, $this->episode->getId()); $this->assertEquals(2, $this->episode->getDvdChapter()); $this->assertEquals(2, $this->episode->getDvdEpisodeNumber()); $this->assertEquals(3, $this->episode->getDvdSeason()); $this->assertEquals(1, $this->episode->getDvdDiscId()); $this->assertEquals(array('Joseph McGinty Nichol'), $this->episode->getDirectors()); $this->assertEquals('Chuck Versus the World', $this->episode->getName()); $this->assertEquals(1, $this->episode->getNumber()); $this->assertEquals(new DateTime('2007-09-24'), $this->episode->getFirstAired()); $this->assertEquals(array('Julia Ling', 'Mieko Hillman', 'Vik Sahay'), $this->episode->getGuestStars()); $this->assertEquals(123, $this->episode->getImdbId()); $this->assertEquals('English', $this->episode->getLanguage()); $this->assertEquals('Chuck Bartowski is an average computer geek...', $this->episode->getOverview()); $this->assertEquals(12, $this->episode->getProductionCode()); $this->assertEquals('9.0', $this->episode->getRating()); $this->assertEquals('10', $this->episode->getRatingCount()); $this->assertEquals(1, $this->episode->getSeason()); $this->assertEquals(array('Chris Fedak', 'Josh Schwartz'), $this->episode->getWriters()); $this->assertEquals(1, $this->episode->getAbsoluteNumber()); $this->assertEquals(1, $this->episode->getAirsAfterSeason()); $this->assertEquals(2, $this->episode->getAirsBeforeEpisode()); $this->assertEquals(3, $this->episode->getAirsBeforeSeason()); $this->assertEquals('episodes/80348-332179.jpg', $this->episode->getThumbnail()); $this->assertEquals(27985, $this->episode->getSeasonId()); $this->assertEquals(80348, $this->episode->getSerieId()); $this->assertEquals(\DateTime::createFromFormat('U', 1201292806), $this->episode->getLastUpdated()); }
public function testIfEpisodeSetupCorrectly() { $xmlData = '<?xml version="1.0" encoding="UTF-8" ?> <Series> <id>80348</id> <Actors>|Zachary Levi|Adam Baldwin|Yvonne Strzechowski|</Actors> <Airs_DayOfWeek>Monday</Airs_DayOfWeek> <Airs_Time>8:00 PM</Airs_Time> <FirstAired>2007-09-24</FirstAired> <Genre>|Comedy|</Genre> <IMDB_ID>tt0934814</IMDB_ID> <Language>English</Language> <Network>NBC</Network> <Overview>Zachary Levi (Less Than Perfect) plays Chuck...</Overview> <Rating>9.0</Rating> <RatingCount>10</RatingCount> <Runtime>30 mins</Runtime> <SeriesID>68724</SeriesID> <SeriesName>Chuck</SeriesName> <Status>Continuing</Status> <lastupdated>1200785226</lastupdated> </Series>'; $data = XmlParser::getXml($xmlData); $this->serie = new Serie($data); $this->assertEquals(80348, $this->serie->getId()); $this->assertEquals('Monday', $this->serie->getAirsDayOfWeek()); $this->assertEquals('8:00 PM', $this->serie->getAirsTime()); $this->assertEquals('tt0934814', $this->serie->getImdbId()); $this->assertEquals('English', $this->serie->getLanguage()); $this->assertEquals('NBC', $this->serie->getNetwork()); $this->assertEquals('9.0', $this->serie->getRating()); $this->assertEquals('10', $this->serie->getRatingCount()); $this->assertEquals('30', $this->serie->getRuntime()); $this->assertEquals('Chuck', $this->serie->getName()); $this->assertEquals('Continuing', $this->serie->getStatus()); $this->assertEquals('Zachary Levi (Less Than Perfect) plays Chuck...', $this->serie->getOverview()); $this->assertEquals('', $this->serie->getBanner()); $this->assertEquals('', $this->serie->getFanart()); $this->assertEquals('', $this->serie->getPoster()); $this->assertEquals(new \DateTime(''), $this->serie->getAdded()); $this->assertEquals(0, $this->serie->getAddedBy()); $this->assertEquals(array('Comedy'), $this->serie->getGenres()); $this->assertEquals('', $this->serie->getZap2ItId()); $this->assertEquals('', $this->serie->getContentRating()); $this->assertEquals(new \DateTime('2007-09-24'), $this->serie->getFirstAired()); $this->assertEquals(\DateTime::createFromFormat('U', 1200785226), $this->serie->getLastUpdated()); $this->assertEquals(array('Adam Baldwin', 'Yvonne Strzechowski', 'Zachary Levi'), $this->serie->getActors()); }
/** * Tests if the correct exception gets thrown when there's an error in the XML * * @expectedException \AxTvDb\Exception\XmlException */ public function testIfExceptionThrownWhenXmlEmpty() { XmlParser::$libXmlLoaded = false; $xmlData = 'test'; XmlParser::getXml($xmlData, false); }
/** * Get a list of mirrors available to fetch data from the api * * @return void */ protected function getMirrors() { $data = CurlDownloader::fetch($this->baseUrl . '/api/' . $this->apiKey . '/mirrors.xml'); $mirrorsXml = XmlParser::getXml($data); $mirrorsArray = array(); foreach ($mirrorsXml->Mirror as $mirror) { $typeMask = (int) $mirror->typemask; $mirrorPath = (string) $mirror->mirrorpath; if ($typeMask & self::MIRROR_TYPE_XML) { $mirrorsArray[self::MIRROR_TYPE_XML][] = $mirrorPath; } if ($typeMask & self::MIRROR_TYPE_BANNER) { $mirrorsArray[self::MIRROR_TYPE_BANNER][] = $mirrorPath; } if ($typeMask & self::MIRROR_TYPE_ZIP) { $mirrorsArray[self::MIRROR_TYPE_ZIP][] = $mirrorPath; } } $this->setMirrors($mirrorsArray); }