diff --git a/lib/Tmdb/Repository/TvSeasonRepository.php b/lib/Tmdb/Repository/TvSeasonRepository.php index 1d34b2c2..104d470e 100644 --- a/lib/Tmdb/Repository/TvSeasonRepository.php +++ b/lib/Tmdb/Repository/TvSeasonRepository.php @@ -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(); @@ -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(); @@ -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(); diff --git a/test/Tmdb/Tests/Repository/TvSeasonRepositoryTest.php b/test/Tmdb/Tests/Repository/TvSeasonRepositoryTest.php index 6bcf3b4b..aa33f4e4 100644 --- a/test/Tmdb/Tests/Repository/TvSeasonRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/TvSeasonRepositoryTest.php @@ -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