Skip to content

Commit

Permalink
Updating TvSeasonRepositoryTest
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfzdotnet committed Feb 23, 2014
1 parent 6b67c60 commit 3362cf9
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 9 deletions.
42 changes: 33 additions & 9 deletions lib/Tmdb/Repository/TvSeasonRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,23 @@ public function load($tvShow, $season, array $parameters = array(), array $heade
*
* Just like the website, we pull this information from the last season of the series.
*
* @param $id
* @param $tvShow
* @param $season
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getCredits($id, $season, array $parameters = array(), array $headers = array())
public function getCredits($tvShow, $season, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getCredits($id, $season, $this->parseQueryParameters($parameters), $headers);
if ($tvShow instanceof Tv) {
$tvShow = $tvShow->getId();
}

if ($season instanceof Season) {
$season = $season->getId();
}

$data = $this->getApi()->getCredits($tvShow, $season, $this->parseQueryParameters($parameters), $headers);
$season = $this->getFactory()->create(array('credits' => $data));

return $season->getCredits();
Expand All @@ -85,15 +93,23 @@ public function getCredits($id, $season, array $parameters = array(), array $hea
/**
* Get the external ids that we have stored for a TV series.
*
* @param $id
* @param $tvShow
* @param $season
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getExternalIds($id, $season, array $parameters = array(), array $headers = array())
public function getExternalIds($tvShow, $season, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getExternalIds($id, $season, $this->parseQueryParameters($parameters), $headers);
if ($tvShow instanceof Tv) {
$tvShow = $tvShow->getId();
}

if ($season instanceof Season) {
$season = $season->getId();
}

$data = $this->getApi()->getExternalIds($tvShow, $season, $this->parseQueryParameters($parameters), $headers);
$season = $this->getFactory()->create(array('external_ids' => $data));

return $season->getExternalIds();
Expand All @@ -102,15 +118,23 @@ public function getExternalIds($id, $season, array $parameters = array(), array
/**
* Get the images (posters and backdrops) for a TV series.
*
* @param $id
* @param $tvShow
* @param $season
* @param $parameters
* @param $headers
* @return null|\Tmdb\Model\AbstractModel
*/
public function getImages($id, $season, array $parameters = array(), array $headers = array())
public function getImages($tvShow, $season, array $parameters = array(), array $headers = array())
{
$data = $this->getApi()->getImages($id, $season, $this->parseQueryParameters($parameters), $headers);
if ($tvShow instanceof Tv) {
$tvShow = $tvShow->getId();
}

if ($season instanceof Season) {
$season = $season->getId();
}

$data = $this->getApi()->getImages($tvShow, $season, $this->parseQueryParameters($parameters), $headers);
$season = $this->getFactory()->create(array('images' => $data));

return $season->getImages();
Expand Down
48 changes: 48 additions & 0 deletions test/Tmdb/Tests/Repository/TvSeasonRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,54 @@ public function shouldBeAbleToLoadTvSeasonWithTvAndSeason()
$repository->load($tv, $season);
}

/**
* @test
*/
public function shouldGetCredits()
{
$repository = $this->getRepositoryWithMockedHttpClient();

$tv = new Tv();
$tv->setId(self::TV_ID);

$season = new Tv\Season();
$season->setId(self::SEASON_ID);

$repository->getCredits($tv, $season);
}

/**
* @test
*/
public function shouldGetExternalIds()
{
$repository = $this->getRepositoryWithMockedHttpClient();

$tv = new Tv();
$tv->setId(self::TV_ID);

$season = new Tv\Season();
$season->setId(self::SEASON_ID);

$repository->getExternalIds($tv, $season);
}

/**
* @test
*/
public function shouldGetImages()
{
$repository = $this->getRepositoryWithMockedHttpClient();

$tv = new Tv();
$tv->setId(self::TV_ID);

$season = new Tv\Season();
$season->setId(self::SEASON_ID);

$repository->getImages($tv, $season);
}

/**
* @expectedException Tmdb\Exception\RuntimeException
* @test
Expand Down

0 comments on commit 3362cf9

Please sign in to comment.