diff --git a/composer.json b/composer.json index 5c737a8d..b1f824f0 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "require": { "php": ">=5.3.2", "ext-curl": "*", - "guzzle/guzzle": "3.8.*", + "guzzle/guzzle": "3.9.*", "psr/log": "~1.0" }, "require-dev": { diff --git a/examples/account/model/favorite_movies.php b/examples/account/model/favorite_movie.php similarity index 100% rename from examples/account/model/favorite_movies.php rename to examples/account/model/favorite_movie.php diff --git a/examples/account/model/favorite.php b/examples/account/model/favorite_movie_add.php similarity index 100% rename from examples/account/model/favorite.php rename to examples/account/model/favorite_movie_add.php diff --git a/examples/account/model/favorite_tv.php b/examples/account/model/favorite_tv.php new file mode 100644 index 00000000..64bbda5f --- /dev/null +++ b/examples/account/model/favorite_tv.php @@ -0,0 +1,28 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once '../../../vendor/autoload.php'; +require_once '../../../apikey.php'; + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN); +$client->setSessionToken($sessionToken); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->getFavoriteTvShows(TMDB_ACCOUNT_ID); + +var_dump($lists); diff --git a/examples/account/model/favorite_tv_add.php b/examples/account/model/favorite_tv_add.php new file mode 100644 index 00000000..0bbf0949 --- /dev/null +++ b/examples/account/model/favorite_tv_add.php @@ -0,0 +1,28 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once '../../../vendor/autoload.php'; +require_once '../../../apikey.php'; + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN); +$client->setSessionToken($sessionToken); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->favorite(TMDB_ACCOUNT_ID, 1973, true, 'tv'); + +var_dump($lists); diff --git a/examples/account/model/rated_tv.php b/examples/account/model/rated_tv.php new file mode 100644 index 00000000..7c90d772 --- /dev/null +++ b/examples/account/model/rated_tv.php @@ -0,0 +1,28 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once '../../../vendor/autoload.php'; +require_once '../../../apikey.php'; + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN); +$client->setSessionToken($sessionToken); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->getRatedTvShows(TMDB_ACCOUNT_ID); + +var_dump($lists); diff --git a/examples/account/model/movie_watchlist.php b/examples/account/model/watchlist_movie.php similarity index 100% rename from examples/account/model/movie_watchlist.php rename to examples/account/model/watchlist_movie.php diff --git a/examples/account/model/watchlist.php b/examples/account/model/watchlist_movie_add.php similarity index 100% rename from examples/account/model/watchlist.php rename to examples/account/model/watchlist_movie_add.php diff --git a/examples/account/model/watchlist_tv.php b/examples/account/model/watchlist_tv.php new file mode 100644 index 00000000..4f741217 --- /dev/null +++ b/examples/account/model/watchlist_tv.php @@ -0,0 +1,28 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once '../../../vendor/autoload.php'; +require_once '../../../apikey.php'; + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN); +$client->setSessionToken($sessionToken); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->getTvWatchlist(TMDB_ACCOUNT_ID); + +var_dump($lists); diff --git a/examples/account/model/watchlist_tv_add.php b/examples/account/model/watchlist_tv_add.php new file mode 100644 index 00000000..9c75e264 --- /dev/null +++ b/examples/account/model/watchlist_tv_add.php @@ -0,0 +1,28 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once '../../../vendor/autoload.php'; +require_once '../../../apikey.php'; + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$sessionToken = new \Tmdb\SessionToken(TMDB_SESSION_TOKEN); +$client->setSessionToken($sessionToken); + +/** + * @var \Tmdb\Repository\AccountRepository $accountRepository + */ +$accountRepository = new \Tmdb\Repository\AccountRepository($client); +$lists = $accountRepository->watchlist(TMDB_ACCOUNT_ID, 1973, true, 'tv'); + +var_dump($lists); diff --git a/examples/changes/api/movies.php b/examples/changes/api/movies.php index 52e9cd28..ec5efe87 100644 --- a/examples/changes/api/movies.php +++ b/examples/changes/api/movies.php @@ -17,9 +17,9 @@ $client = new \Tmdb\Client($token); $movieChanges = $client->getChangesApi()->getMovieChanges(array( - 'page' => 1, - 'from' => '01-01-2012', - 'to' => '08-01-2012' + 'page' => 1, + 'start_date' => '2014-01-01', + 'end_date' => '2014-01-02' )); var_dump($movieChanges); diff --git a/examples/changes/api/people.php b/examples/changes/api/people.php index beb744ab..4ff9b18f 100644 --- a/examples/changes/api/people.php +++ b/examples/changes/api/people.php @@ -17,9 +17,9 @@ $client = new \Tmdb\Client($token); $personChanges = $client->getChangesApi()->getPersonChanges(array( - 'page' => 1, - 'from' => '01-01-2012', - 'to' => '08-01-2012' + 'page' => 1, + 'start_date' => '2014-01-14', + 'end_date' => '2014-01-21' )); var_dump($personChanges); diff --git a/examples/changes/model/movies.php b/examples/changes/model/movies.php index 309aea34..c01b52be 100644 --- a/examples/changes/model/movies.php +++ b/examples/changes/model/movies.php @@ -18,8 +18,8 @@ $query = new \Tmdb\Model\Query\ChangesQuery(); -$from = new \DateTime('01-01-2012'); -$to = new \DateTime('08-01-2012'); +$from = new \DateTime('01-01-2014'); +$to = new \DateTime('02-01-2014'); $query ->page(1) diff --git a/examples/changes/model/people.php b/examples/changes/model/people.php index f6a90c17..2778e00d 100644 --- a/examples/changes/model/people.php +++ b/examples/changes/model/people.php @@ -18,8 +18,8 @@ $query = new \Tmdb\Model\Query\ChangesQuery(); -$from = new \DateTime('01-01-2012'); -$to = new \DateTime('08-01-2012'); +$from = new \DateTime('14-01-2014'); +$to = new \DateTime('21-01-2014'); $query ->page(1) diff --git a/examples/movies/api/similar_movies.php b/examples/movies/api/similar.php similarity index 88% rename from examples/movies/api/similar_movies.php rename to examples/movies/api/similar.php index 2331e709..a756e623 100644 --- a/examples/movies/api/similar_movies.php +++ b/examples/movies/api/similar.php @@ -16,6 +16,6 @@ $token = new \Tmdb\ApiToken(TMDB_API_KEY); $client = new \Tmdb\Client($token); -$similarMovies = $client->getMoviesApi()->getSimilarMovies(87421); +$similarMovies = $client->getMoviesApi()->getSimilar(87421); var_dump($similarMovies); diff --git a/examples/movies/model/similar_movies.php b/examples/movies/model/similar.php similarity index 91% rename from examples/movies/model/similar_movies.php rename to examples/movies/model/similar.php index 723d4882..30e38f21 100644 --- a/examples/movies/model/similar_movies.php +++ b/examples/movies/model/similar.php @@ -17,6 +17,6 @@ $client = new \Tmdb\Client($token); $repository = new \Tmdb\Repository\MovieRepository($client); -$collection = $repository->getSimilarMovies(87421); +$collection = $repository->getSimilar(87421); var_dump($collection); diff --git a/examples/people/api/tagged_images.php b/examples/people/api/tagged_images.php new file mode 100644 index 00000000..2f118ca7 --- /dev/null +++ b/examples/people/api/tagged_images.php @@ -0,0 +1,21 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once '../../../vendor/autoload.php'; +require_once '../../../apikey.php'; + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$taggedImages = $client->getPeopleApi()->getTaggedImages(287); + +var_dump($taggedImages); diff --git a/examples/people/model/tagged_images.php b/examples/people/model/tagged_images.php new file mode 100644 index 00000000..a92cfac5 --- /dev/null +++ b/examples/people/model/tagged_images.php @@ -0,0 +1,22 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once '../../../vendor/autoload.php'; +require_once '../../../apikey.php'; + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$repository = new \Tmdb\Repository\PeopleRepository($client); +$person = $repository->getTaggedImages(287); + +var_dump($person); diff --git a/examples/tv/api/tv/latest.php b/examples/tv/api/tv/latest.php new file mode 100644 index 00000000..75f412dc --- /dev/null +++ b/examples/tv/api/tv/latest.php @@ -0,0 +1,21 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once '../../../vendor/autoload.php'; +require_once '../../../apikey.php'; + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$tvShow = $client->getTvApi()->getLatest(); + +var_dump($tvShow); diff --git a/examples/tv/model/tv/latest.php b/examples/tv/model/tv/latest.php new file mode 100644 index 00000000..503c50e4 --- /dev/null +++ b/examples/tv/model/tv/latest.php @@ -0,0 +1,22 @@ + + * @copyright (c) 2013, Michael Roterman + * @version 0.0.1 + */ +require_once '../../../vendor/autoload.php'; +require_once '../../../apikey.php'; + +$token = new \Tmdb\ApiToken(TMDB_API_KEY); +$client = new \Tmdb\Client($token); + +$repository = new \Tmdb\Repository\TvRepository($client); +$tvShow = $repository->getLatest(); + +var_dump($tvShow); diff --git a/lib/Tmdb/Api/Movies.php b/lib/Tmdb/Api/Movies.php index 242a643a..35998601 100644 --- a/lib/Tmdb/Api/Movies.php +++ b/lib/Tmdb/Api/Movies.php @@ -131,10 +131,25 @@ public function getTranslations($movie_id, array $parameters = array(), array $h * @param array $parameters * @param array $headers * @return mixed + * + * @deprecated Will be removed in one of the upcoming versions, has been updated to getSimilar ( following TMDB ). */ public function getSimilarMovies($movie_id, array $parameters = array(), array $headers = array()) { - return $this->get('movie/' . $movie_id . '/similar_movies', $parameters, $headers); + return $this->getSimilar($movie_id, $parameters, $headers); + } + + /** + * Get the similar movies for a specific movie id. + * + * @param $movie_id + * @param array $parameters + * @param array $headers + * @return mixed + */ + public function getSimilar($movie_id, array $parameters = array(), array $headers = array()) + { + return $this->get('movie/' . $movie_id . '/similar', $parameters, $headers); } /** diff --git a/lib/Tmdb/Api/People.php b/lib/Tmdb/Api/People.php index cd379813..b9457cee 100644 --- a/lib/Tmdb/Api/People.php +++ b/lib/Tmdb/Api/People.php @@ -135,6 +135,23 @@ public function getExternalIds($person_id, array $parameters = array(), array $h return $this->get('person/' . $person_id . '/external_ids', $parameters, $headers); } + /** + * Get the images that have been tagged with a specific person id. + * + * We return all of the image results with a media object mapped for each image. + * + * @param $person_id + * @param array $parameters + * @param array $headers + * @return mixed + * + * @todo Still does not contain the media and media_type properties, this will be worked on later on. + */ + public function getTaggedImages($person_id, array $parameters = array(), array $headers = array()) + { + return $this->get('person/' . $person_id . '/tagged_images', $parameters, $headers); + } + /** * Get the list of popular people on The Movie Database. This list refreshes every day. * diff --git a/lib/Tmdb/Api/Tv.php b/lib/Tmdb/Api/Tv.php index 68ebb63b..af809291 100644 --- a/lib/Tmdb/Api/Tv.php +++ b/lib/Tmdb/Api/Tv.php @@ -154,4 +154,66 @@ public function getVideos($tvshow_id, array $parameters = array(), array $header { return $this->get('tv/' . $tvshow_id . '/videos', $parameters, $headers); } + + /** + * Get the changes for a specific TV show id. + * + * Changes are grouped by key, and ordered by date in descending order. + * By default, only the last 24 hours of changes are returned. + * The maximum number of days that can be returned in a single request is 14. + * The language is present on fields that are translatable. + * + * TV changes are different than movie changes in that there are some edits on seasons and episodes + * that will create a change entry at the show level. They can be found under the season and episode keys. + * These keys will contain a series_id and episode_id. + * + * You can use the /tv/season/{id}/changes and /tv/episode/{id}/changes methods to look up these specific changes. + * + * @param $tvshow_id + * @param array $parameters + * @param array $headers + * @return mixed + */ + public function getChanges($tvshow_id, array $parameters = array(), array $headers = array()) + { + return $this->get('tv/' . $tvshow_id . '/changes', $parameters, $headers); + } + + /** + * Get the latest TV show id. + * + * @param array $parameters + * @param array $headers + * @return mixed + */ + public function getLatest(array $parameters = array(), array $headers = array()) + { + return $this->get('tv/latest', $parameters, $headers); + } + + /** + * Get the plot keywords for a specific TV show id. + * + * @param $tvshow_id + * @param array $parameters + * @param array $headers + * @return mixed + */ + public function getKeywords($tvshow_id, array $parameters = array(), array $headers = array()) + { + return $this->get('tv/' . $tvshow_id . '/keywords', $parameters, $headers); + } + + /** + * Get the similar TV shows for a specific tv id. + * + * @param $tvshow_id + * @param array $parameters + * @param array $headers + * @return mixed + */ + public function getSimilar($tvshow_id, array $parameters = array(), array $headers = array()) + { + return $this->get('tv/' . $tvshow_id . '/similar', $parameters, $headers); + } } diff --git a/lib/Tmdb/Api/TvEpisode.php b/lib/Tmdb/Api/TvEpisode.php index 2a15f48f..262f6007 100644 --- a/lib/Tmdb/Api/TvEpisode.php +++ b/lib/Tmdb/Api/TvEpisode.php @@ -163,4 +163,37 @@ public function getVideos( $headers ); } + + /** + * Look up a TV episode's changes by episode ID. + * + * This method is used in conjunction with the /tv/{id}/changes method. + * This method uses the episode_id value found in the change entries. + * + * @param $tvshow_id + * @param $season_number + * @param $episode_number + * @param array $parameters + * @param array $headers + * @return mixed + */ + public function getChanges( + $tvshow_id, + $season_number, + $episode_number, + array $parameters = array(), + array $headers = array() + ) { + return $this->get( + sprintf( + 'tv/%s/season/%s/episode/%s/changes', + $tvshow_id, + $season_number, + $episode_number + ), + $parameters, + $headers + ); + } + } diff --git a/lib/Tmdb/Api/TvSeason.php b/lib/Tmdb/Api/TvSeason.php index 5085dee1..4a64e0e5 100644 --- a/lib/Tmdb/Api/TvSeason.php +++ b/lib/Tmdb/Api/TvSeason.php @@ -88,4 +88,21 @@ public function getVideos($tvshow_id, $season_number, array $parameters = array( { return $this->get(sprintf('tv/%s/season/%s/videos', $tvshow_id, $season_number), $parameters, $headers); } + + /** + * Look up a TV season's changes by season ID. + * This method is used in conjunction with the /tv/{id}/changes method. + * + * This method uses the season_id value found in the change entries. + * + * @param integer $tvshow_id + * @param integer $season_number + * @param array $parameters + * @param array $headers + * @return mixed + */ + public function getChanges($tvshow_id, $season_number, array $parameters = array(), array $headers = array()) + { + return $this->get(sprintf('tv/%s/season/%s/changes', $tvshow_id, $season_number), $parameters, $headers); + } } diff --git a/lib/Tmdb/Factory/AccountFactory.php b/lib/Tmdb/Factory/AccountFactory.php index a3289bb9..074e4f12 100644 --- a/lib/Tmdb/Factory/AccountFactory.php +++ b/lib/Tmdb/Factory/AccountFactory.php @@ -32,10 +32,16 @@ class AccountFactory extends AbstractFactory */ private $imageFactory; + /** + * @var TvFactory + */ + private $tvFactory; + public function __construct() { $this->movieFactory = new MovieFactory(); $this->imageFactory = new ImageFactory(); + $this->tvFactory = new TvFactory(); } /** @@ -69,6 +75,17 @@ public function createMovie(array $data = array()) return $this->getMovieFactory()->create($data); } + /** + * Create TV show + * + * @param array $data + * @return \Tmdb\Model\Tv + */ + public function createTvShow(array $data = array()) + { + return $this->getTvFactory()->create($data); + } + /** * Create list item * @@ -131,4 +148,23 @@ public function getImageFactory() { return $this->imageFactory; } + + /** + * @param \Tmdb\Factory\TvFactory $tvFactory + * @return $this + */ + public function setTvFactory($tvFactory) + { + $this->tvFactory = $tvFactory; + + return $this; + } + + /** + * @return \Tmdb\Factory\TvFactory + */ + public function getTvFactory() + { + return $this->tvFactory; + } } diff --git a/lib/Tmdb/Factory/MovieFactory.php b/lib/Tmdb/Factory/MovieFactory.php index 56ff7e45..fcba1d7e 100644 --- a/lib/Tmdb/Factory/MovieFactory.php +++ b/lib/Tmdb/Factory/MovieFactory.php @@ -168,8 +168,8 @@ public function create(array $data = array()) ); } - if (array_key_exists('similar_movies', $data)) { - $movie->setSimilarMovies($this->createResultCollection($data['similar_movies'])); + if (array_key_exists('similar', $data)) { + $movie->setSimilar($this->createResultCollection($data['similar'])); } if (array_key_exists('reviews', $data)) { diff --git a/lib/Tmdb/Factory/PeopleFactory.php b/lib/Tmdb/Factory/PeopleFactory.php index 98c77db1..f4db86bc 100644 --- a/lib/Tmdb/Factory/PeopleFactory.php +++ b/lib/Tmdb/Factory/PeopleFactory.php @@ -88,6 +88,14 @@ public function create(array $data = array(), $person = null) ); } + if (array_key_exists('tagged_images', $data)) { + $person->setTaggedImages( + $this->getImageFactory()->createResultCollection( + $data['tagged_images'] + ) + ); + } + return $this->hydrate($person, $data); } diff --git a/lib/Tmdb/Factory/TvEpisodeFactory.php b/lib/Tmdb/Factory/TvEpisodeFactory.php index cabdf35b..f5df88d5 100644 --- a/lib/Tmdb/Factory/TvEpisodeFactory.php +++ b/lib/Tmdb/Factory/TvEpisodeFactory.php @@ -12,6 +12,7 @@ */ namespace Tmdb\Factory; +use Tmdb\Factory\Common\ChangeFactory; use Tmdb\Factory\Common\VideoFactory; use Tmdb\Factory\People\CastFactory; use Tmdb\Factory\People\CrewFactory; @@ -47,15 +48,21 @@ class TvEpisodeFactory extends AbstractFactory */ private $videoFactory; + /** + * @var Common\ChangeFactory + */ + private $changesFactory; + /** * Constructor */ public function __construct() { - $this->castFactory = new CastFactory(); - $this->crewFactory = new CrewFactory(); - $this->imageFactory = new ImageFactory(); - $this->videoFactory = new VideoFactory(); + $this->castFactory = new CastFactory(); + $this->crewFactory = new CrewFactory(); + $this->imageFactory = new ImageFactory(); + $this->videoFactory = new VideoFactory(); + $this->changesFactory = new ChangeFactory(); } /** @@ -112,6 +119,10 @@ public function create(array $data = array()) $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); } @@ -204,4 +215,23 @@ public function getVideoFactory() { return $this->videoFactory; } + + /** + * @param \Tmdb\Factory\Common\ChangeFactory $changesFactory + * @return $this + */ + public function setChangesFactory($changesFactory) + { + $this->changesFactory = $changesFactory; + + return $this; + } + + /** + * @return \Tmdb\Factory\Common\ChangeFactory + */ + public function getChangesFactory() + { + return $this->changesFactory; + } } diff --git a/lib/Tmdb/Factory/TvFactory.php b/lib/Tmdb/Factory/TvFactory.php index 308d40bf..6afee4de 100644 --- a/lib/Tmdb/Factory/TvFactory.php +++ b/lib/Tmdb/Factory/TvFactory.php @@ -12,6 +12,7 @@ */ namespace Tmdb\Factory; +use Tmdb\Factory\Common\ChangeFactory; use Tmdb\Factory\Common\VideoFactory; use Tmdb\Factory\People\CastFactory; use Tmdb\Factory\People\CrewFactory; @@ -63,6 +64,16 @@ class TvFactory extends AbstractFactory */ private $videoFactory; + /** + * @var ChangeFactory + */ + private $changesFactory; + + /** + * @var KeywordFactory + */ + private $keywordFactory; + /** * Constructor */ @@ -75,6 +86,8 @@ public function __construct() $this->tvSeasonFactory = new TvSeasonFactory(); $this->networkFactory = new NetworkFactory(); $this->videoFactory = new VideoFactory(); + $this->changesFactory = new ChangeFactory(); + $this->keywordFactory = new KeywordFactory(); } /** @@ -169,6 +182,18 @@ public function create(array $data = array()) $tvShow->setVideos($this->getVideoFactory()->createCollection($data['videos'])); } + if (array_key_exists('keywords', $data) && array_key_exists('results', $data['keywords'])) { + $tvShow->setKeywords($this->getKeywordFactory()->createCollection($data['keywords']['results'])); + } + + if (array_key_exists('changes', $data)) { + $tvShow->setChanges($this->getChangesFactory()->createCollection($data['changes'])); + } + + if (array_key_exists('similar', $data)) { + $tvShow->setSimilar($this->createResultCollection($data['similar'])); + } + return $this->hydrate($tvShow, $data); } @@ -322,4 +347,42 @@ public function getVideoFactory() { return $this->videoFactory; } + + /** + * @param \Tmdb\Factory\Common\ChangeFactory $changesFactory + * @return $this + */ + public function setChangesFactory($changesFactory) + { + $this->changesFactory = $changesFactory; + + return $this; + } + + /** + * @return \Tmdb\Factory\Common\ChangeFactory + */ + public function getChangesFactory() + { + return $this->changesFactory; + } + + /** + * @param \Tmdb\Factory\KeywordFactory $keywordFactory + * @return $this + */ + public function setKeywordFactory($keywordFactory) + { + $this->keywordFactory = $keywordFactory; + + return $this; + } + + /** + * @return \Tmdb\Factory\KeywordFactory + */ + public function getKeywordFactory() + { + return $this->keywordFactory; + } } diff --git a/lib/Tmdb/Factory/TvSeasonFactory.php b/lib/Tmdb/Factory/TvSeasonFactory.php index ade7b6ed..00afa3fa 100644 --- a/lib/Tmdb/Factory/TvSeasonFactory.php +++ b/lib/Tmdb/Factory/TvSeasonFactory.php @@ -12,6 +12,7 @@ */ namespace Tmdb\Factory; +use Tmdb\Factory\Common\ChangeFactory; use Tmdb\Factory\Common\VideoFactory; use Tmdb\Factory\People\CastFactory; use Tmdb\Factory\People\CrewFactory; @@ -52,6 +53,11 @@ class TvSeasonFactory extends AbstractFactory */ private $videoFactory; + /** + * @var ChangeFactory + */ + private $changesFactory; + /** * Constructor */ @@ -62,6 +68,8 @@ public function __construct() $this->imageFactory = new ImageFactory(); $this->tvEpisodeFactory = new TvEpisodeFactory(); $this->videoFactory = new VideoFactory(); + $this->changesFactory = new ChangeFactory(); + } /** @@ -120,6 +128,10 @@ public function create(array $data = array()) $tvSeason->setVideos($this->getVideoFactory()->createCollection($data['videos'])); } + if (array_key_exists('changes', $data)) { + $tvSeason->setChanges($this->getChangesFactory()->createCollection($data['changes'])); + } + return $this->hydrate($tvSeason, $data); } @@ -231,4 +243,23 @@ public function getVideoFactory() { return $this->videoFactory; } + + /** + * @param \Tmdb\Factory\Common\ChangeFactory $changesFactory + * @return $this + */ + public function setChangesFactory($changesFactory) + { + $this->changesFactory = $changesFactory; + + return $this; + } + + /** + * @return \Tmdb\Factory\Common\ChangeFactory + */ + public function getChangesFactory() + { + return $this->changesFactory; + } } diff --git a/lib/Tmdb/Model/Movie.php b/lib/Tmdb/Model/Movie.php index 4e8c678a..8e7e4f9c 100644 --- a/lib/Tmdb/Model/Movie.php +++ b/lib/Tmdb/Model/Movie.php @@ -197,7 +197,7 @@ class Movie extends AbstractModel /** * @var Collection */ - protected $similarMovies; + protected $similar; /** * @var Collection @@ -266,7 +266,7 @@ public function __construct() $this->keywords = new GenericCollection(); $this->lists = new GenericCollection(); $this->releases = new GenericCollection(); - $this->similarMovies = new GenericCollection(); + $this->similar = new GenericCollection(); $this->trailers = new GenericCollection(); $this->translations = new GenericCollection(); $this->videos = new Videos(); @@ -847,12 +847,12 @@ public function getReleases() } /** - * @param GenericCollection $similarMovies + * @param GenericCollection $similar * @return $this */ - public function setSimilarMovies($similarMovies) + public function setSimilar($similar) { - $this->similarMovies = $similarMovies; + $this->similar = $similar; return $this; } @@ -860,9 +860,18 @@ public function setSimilarMovies($similarMovies) /** * @return Movie[] */ + public function getSimilar() + { + return $this->similar; + } + + /** + * @return Movie[] + * @deprecated + */ public function getSimilarMovies() { - return $this->similarMovies; + return $this->getSimilar(); } /** diff --git a/lib/Tmdb/Model/Movie/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Movie/QueryParameter/AppendToResponse.php index 2e5daf92..baeeeab5 100644 --- a/lib/Tmdb/Model/Movie/QueryParameter/AppendToResponse.php +++ b/lib/Tmdb/Model/Movie/QueryParameter/AppendToResponse.php @@ -27,7 +27,7 @@ final class AppendToResponse extends BaseAppendToResponse const RELEASES = 'releases'; const TRAILERS = 'trailers'; const TRANSLATIONS = 'translations'; - const SIMILAR_MOVIES = 'similar_movies'; + const SIMILAR_MOVIES = 'similar'; const REVIEWS = 'reviews'; const LISTS = 'lists'; const CHANGES = 'changes'; diff --git a/lib/Tmdb/Model/Person.php b/lib/Tmdb/Model/Person.php index d2a8db30..b1bbd9e4 100644 --- a/lib/Tmdb/Model/Person.php +++ b/lib/Tmdb/Model/Person.php @@ -117,6 +117,11 @@ class Person extends AbstractModel implements PersonInterface */ protected $externalIds; + /** + * @var GenericCollection + */ + protected $taggedImages; + public static $properties = array( 'adult', 'also_known_as', @@ -499,4 +504,23 @@ public function getExternalIds() { return $this->externalIds; } + + /** + * @param mixed $taggedImages + * @return $this + */ + public function setTaggedImages($taggedImages) + { + $this->taggedImages = $taggedImages; + + return $this; + } + + /** + * @return mixed + */ + public function getTaggedImages() + { + return $this->taggedImages; + } } diff --git a/lib/Tmdb/Model/Person/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Person/QueryParameter/AppendToResponse.php index 9ecb80c1..68e19875 100644 --- a/lib/Tmdb/Model/Person/QueryParameter/AppendToResponse.php +++ b/lib/Tmdb/Model/Person/QueryParameter/AppendToResponse.php @@ -26,4 +26,5 @@ final class AppendToResponse extends BaseAppendToResponse const IMAGES = 'images'; const CHANGES = 'changes'; const EXTERNAL_IDS = 'external_ids'; + const TAGGED_IMAGES = 'tagged_images'; } diff --git a/lib/Tmdb/Model/Query/ChangesQuery.php b/lib/Tmdb/Model/Query/ChangesQuery.php index 886a047e..e97babed 100644 --- a/lib/Tmdb/Model/Query/ChangesQuery.php +++ b/lib/Tmdb/Model/Query/ChangesQuery.php @@ -28,7 +28,7 @@ class ChangesQuery extends QueryParametersCollection */ public function from(\DateTime $date) { - $this->set('from', $date->format('Y-m-d')); + $this->set('start_date', $date->format('Y-m-d')); return $this; } @@ -41,7 +41,7 @@ public function from(\DateTime $date) */ public function to(\DateTime $date) { - $this->set('to', $date->format('Y-m-d')); + $this->set('end_date', $date->format('Y-m-d')); return $this; } diff --git a/lib/Tmdb/Model/Tv.php b/lib/Tmdb/Model/Tv.php index e24b4308..8087ee5f 100644 --- a/lib/Tmdb/Model/Tv.php +++ b/lib/Tmdb/Model/Tv.php @@ -185,6 +185,21 @@ class Tv extends AbstractModel */ protected $videos; + /** + * @var Common\GenericCollection + */ + protected $changes; + + /** + * @var Common\GenericCollection + */ + protected $keywords; + + /** + * @var Common\GenericCollection + */ + protected $similar; + /** * Properties that are available in the API * @@ -235,6 +250,9 @@ public function __construct() $this->images = new Images(); $this->translations = new GenericCollection(); $this->videos = new Videos(); + $this->changes = new GenericCollection(); + $this->keywords = new GenericCollection(); + $this->similar = new GenericCollection(); } /** @@ -814,4 +832,61 @@ public function getVideos() { return $this->videos; } + + /** + * @param \Tmdb\Model\Common\GenericCollection $changes + * @return $this + */ + public function setChanges($changes) + { + $this->changes = $changes; + + return $this; + } + + /** + * @return \Tmdb\Model\Common\GenericCollection + */ + public function getChanges() + { + return $this->changes; + } + + /** + * @param \Tmdb\Model\Common\GenericCollection $keywords + * @return $this + */ + public function setKeywords($keywords) + { + $this->keywords = $keywords; + + return $this; + } + + /** + * @return \Tmdb\Model\Common\GenericCollection + */ + public function getKeywords() + { + return $this->keywords; + } + + /** + * @param \Tmdb\Model\Common\GenericCollection $similar + * @return $this + */ + public function setSimilar($similar) + { + $this->similar = $similar; + + return $this; + } + + /** + * @return \Tmdb\Model\Common\GenericCollection + */ + public function getSimilar() + { + return $this->similar; + } } diff --git a/lib/Tmdb/Model/Tv/Episode.php b/lib/Tmdb/Model/Tv/Episode.php index 5fedb215..84a7ebac 100644 --- a/lib/Tmdb/Model/Tv/Episode.php +++ b/lib/Tmdb/Model/Tv/Episode.php @@ -13,6 +13,7 @@ namespace Tmdb\Model\Tv; use Tmdb\Model\AbstractModel; +use Tmdb\Model\Collection\Changes; use Tmdb\Model\Collection\CreditsCollection; use Tmdb\Model\Collection\Images; use Tmdb\Model\Collection\Videos; @@ -107,6 +108,8 @@ class Episode extends AbstractModel */ protected $videos; + protected $changes; + /** * Properties that are available in the API * @@ -136,6 +139,7 @@ public function __construct() $this->externalIds = new ExternalIds(); $this->images = new Images(); $this->videos = new Videos(); + $this->changes = new Changes(); } /** @@ -426,4 +430,23 @@ public function getVideos() { return $this->videos; } + + /** + * @param \Tmdb\Model\Collection\Changes $changes + * @return $this + */ + public function setChanges($changes) + { + $this->changes = $changes; + + return $this; + } + + /** + * @return \Tmdb\Model\Collection\Changes + */ + public function getChanges() + { + return $this->changes; + } } diff --git a/lib/Tmdb/Model/Tv/Episode/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Tv/Episode/QueryParameter/AppendToResponse.php index 283464c5..4f052e2e 100644 --- a/lib/Tmdb/Model/Tv/Episode/QueryParameter/AppendToResponse.php +++ b/lib/Tmdb/Model/Tv/Episode/QueryParameter/AppendToResponse.php @@ -24,4 +24,5 @@ class AppendToResponse extends BaseAppendToResponse const EXTERNAL_IDS = 'external_ids'; const IMAGES = 'images'; const VIDEOS = 'videos'; + const CHANGES = 'changes'; } diff --git a/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php index b1cb0615..4d424b41 100644 --- a/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php +++ b/lib/Tmdb/Model/Tv/QueryParameter/AppendToResponse.php @@ -25,4 +25,7 @@ class AppendToResponse extends BaseAppendToResponse const IMAGES = 'images'; const TRANSLATIONS = 'translations'; const VIDEOS = 'videos'; + const CHANGES = 'changes'; + const KEYWORDS = 'keywords'; + const SIMILAR = 'similar'; } diff --git a/lib/Tmdb/Model/Tv/Season.php b/lib/Tmdb/Model/Tv/Season.php index bd8b6f5c..5d3b11a8 100644 --- a/lib/Tmdb/Model/Tv/Season.php +++ b/lib/Tmdb/Model/Tv/Season.php @@ -13,6 +13,7 @@ namespace Tmdb\Model\Tv; use Tmdb\Model\AbstractModel; +use Tmdb\Model\Collection\Changes; use Tmdb\Model\Collection\CreditsCollection; use Tmdb\Model\Collection\Images; use Tmdb\Model\Collection\Videos; @@ -93,6 +94,11 @@ class Season extends AbstractModel */ protected $videos; + /** + * @var \Tmdb\Model\Collection\Changes + */ + protected $changes; + /** * Properties that are available in the API * @@ -119,6 +125,7 @@ public function __construct() $this->images = new Images(); $this->episodes = new GenericCollection(); $this->videos = new Videos(); + $this->changes = new Changes(); } /** @@ -348,4 +355,23 @@ public function getVideos() { return $this->videos; } + + /** + * @param \Tmdb\Model\Collection\Changes $changes + * @return $this + */ + public function setChanges($changes) + { + $this->changes = $changes; + + return $this; + } + + /** + * @return \Tmdb\Model\Collection\Changes + */ + public function getChanges() + { + return $this->changes; + } } diff --git a/lib/Tmdb/Model/Tv/Season/QueryParameter/AppendToResponse.php b/lib/Tmdb/Model/Tv/Season/QueryParameter/AppendToResponse.php index b48d3480..597d4282 100644 --- a/lib/Tmdb/Model/Tv/Season/QueryParameter/AppendToResponse.php +++ b/lib/Tmdb/Model/Tv/Season/QueryParameter/AppendToResponse.php @@ -24,4 +24,5 @@ class AppendToResponse extends BaseAppendToResponse const EXTERNAL_IDS = 'external_ids'; const IMAGES = 'images'; const VIDEOS = 'videos'; + const CHANGES = 'changes'; } diff --git a/lib/Tmdb/Repository/AccountRepository.php b/lib/Tmdb/Repository/AccountRepository.php index 19e26247..ae895f67 100644 --- a/lib/Tmdb/Repository/AccountRepository.php +++ b/lib/Tmdb/Repository/AccountRepository.php @@ -15,6 +15,7 @@ use Tmdb\Factory\AccountFactory; use Tmdb\Model\Collection\ResultCollection; use Tmdb\Model\Movie; +use Tmdb\Model\Tv; /** * Class AccountRepository @@ -66,21 +67,40 @@ public function getFavoriteMovies($accountId, array $parameters = array(), array return $this->getFactory()->createResultCollection($data, 'createMovie'); } + /** + * Get the list of favorite movies for an account. + * + * @param string $accountId + * @param array $parameters + * @param array $headers + * @return ResultCollection + */ + public function getFavoriteTvShows($accountId, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getFavoriteTvShows($accountId, $parameters, $headers); + + return $this->getFactory()->createResultCollection($data, 'createTvShow'); + } + /** * Add or remove a movie to an accounts favorite list. * * @param string $accountId - * @param int|Movie $movie + * @param int|Movie|Tv $media * @param boolean $isFavorite * @return ResultCollection */ - public function favorite($accountId, $movie, $isFavorite = true) + public function favorite($accountId, $media, $isFavorite = true) { - if ($movie instanceof Movie) { - $movie = $movie->getId(); + if ($media instanceof Movie) { + $media = $media->getId(); } - $data = $this->getApi()->favorite($accountId, $movie, $isFavorite); + if ($media instanceof Tv) { + $media = $media->getId(); + } + + $data = $this->getApi()->favorite($accountId, $media, $isFavorite); return $this->getFactory()->createStatusResult($data); } @@ -92,6 +112,8 @@ public function favorite($accountId, $movie, $isFavorite = true) * @param array $parameters * @param array $headers * @return ResultCollection + * + * @todo Include the user rating */ public function getRatedMovies($accountId, array $parameters = array(), array $headers = array()) { @@ -100,6 +122,23 @@ public function getRatedMovies($accountId, array $parameters = array(), array $h return $this->getFactory()->createResultCollection($data, 'createMovie'); } + /** + * Get the list of rated TV shows (and associated rating) for an account. + * + * @param string $accountId + * @param array $parameters + * @param array $headers + * @return ResultCollection + * + * @todo Include the user rating + */ + public function getRatedTvShows($accountId, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getRatedTvShows($accountId, $parameters, $headers); + + return $this->getFactory()->createResultCollection($data, 'createTvShow'); + } + /** * Get the list of movies on an accounts watchlist. * @@ -116,20 +155,40 @@ public function getMovieWatchlist($accountId, array $parameters = array(), array } /** - * Add or remove a movie to an accounts watch list. + * Get the list of TV series on an accounts watchlist. * * @param string $accountId - * @param int|Movie $movie - * @param boolean $isOnWatchlist + * @param array $parameters + * @param array $headers * @return ResultCollection */ - public function watchlist($accountId, $movie, $isOnWatchlist = true) + public function getTvWatchlist($accountId, array $parameters = array(), array $headers = array()) { - if ($movie instanceof Movie) { - $movie = $movie->getId(); + $data = $this->getApi()->getTvWatchlist($accountId, $parameters, $headers); + + return $this->getFactory()->createResultCollection($data, 'createTvShow'); + } + + /** + * Add or remove a movie to an accounts watch list. + * + * @param string $accountId + * @param integer $media + * @param bool $isOnWatchlist + * @param string $mediaType + * @return \Tmdb\Model\Lists\Result + */ + public function watchlist($accountId, $media, $isOnWatchlist = true, $mediaType = 'movie') + { + if ($media instanceof Movie || $media instanceof Tv) { + $media = $media->getId(); + } + + if ($media instanceof Tv) { + $mediaType = 'tv'; } - $data = $this->getApi()->watchlist($accountId, $movie, $isOnWatchlist); + $data = $this->getApi()->watchlist($accountId, $media, $isOnWatchlist, $mediaType); return $this->getFactory()->createStatusResult($data); } diff --git a/lib/Tmdb/Repository/MovieRepository.php b/lib/Tmdb/Repository/MovieRepository.php index 58f65dca..88e6da27 100644 --- a/lib/Tmdb/Repository/MovieRepository.php +++ b/lib/Tmdb/Repository/MovieRepository.php @@ -200,13 +200,28 @@ public function getTranslations($id, array $parameters = array(), array $headers * @param $parameters * @param $headers * @return null|\Tmdb\Model\AbstractModel + * + * @deprecated Will be removed in one of the upcoming versions, has been updated to getSimilar ( following TMDB ). */ public function getSimilarMovies($id, array $parameters = array(), array $headers = array()) { - $data = $this->getApi()->getSimilarMovies($id, $this->parseQueryParameters($parameters), $headers); - $movie = $this->getFactory()->create(array('similar_movies' => $data)); + return $this->getSimilar($id, $parameters, $headers); + } + + /** + * Get the similar movies for a specific movie id. + * + * @param $id + * @param $parameters + * @param $headers + * @return null|\Tmdb\Model\AbstractModel + */ + public function getSimilar($id, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getSimilar($id, $this->parseQueryParameters($parameters), $headers); + $movie = $this->getFactory()->create(array('similar' => $data)); - return $movie->getSimilarMovies(); + return $movie->getSimilar(); } /** diff --git a/lib/Tmdb/Repository/PeopleRepository.php b/lib/Tmdb/Repository/PeopleRepository.php index c09c87be..15b24dfa 100644 --- a/lib/Tmdb/Repository/PeopleRepository.php +++ b/lib/Tmdb/Repository/PeopleRepository.php @@ -44,7 +44,8 @@ public function load($id, array $parameters = array(), array $headers = array()) AppendToResponse::COMBINED_CREDITS, AppendToResponse::MOVIE_CREDITS, AppendToResponse::TV_CREDITS, - AppendToResponse::EXTERNAL_IDS + AppendToResponse::EXTERNAL_IDS, + AppendToResponse::TAGGED_IMAGES )) ); } @@ -162,6 +163,28 @@ public function getChanges($id, array $parameters = array(), array $headers = ar return $person->getChanges(); } + /** + * Get the changes for a specific person id. + * + * Changes are grouped by key, and ordered by date in descending order. + * + * By default, only the last 24 hours of changes are returned. + * The maximum number of days that can be returned in a single request is 14. + * The language is present on fields that are translatable. + * + * @param $id + * @param array $parameters + * @param array $headers + * @return null|\Tmdb\Model\AbstractModel + */ + public function getTaggedImages($id, array $parameters = array(), array $headers = array()) + { + $data = $this->getApi()->getTaggedImages($id, $this->parseQueryParameters($parameters), $headers); + $person = $this->getFactory()->create(array('tagged_images' => $data)); + + return $person->getTaggedImages(); + } + /** * Get the list of popular people on The Movie Database. * diff --git a/lib/Tmdb/Repository/TvEpisodeRepository.php b/lib/Tmdb/Repository/TvEpisodeRepository.php index 18f3882f..d639b0e0 100644 --- a/lib/Tmdb/Repository/TvEpisodeRepository.php +++ b/lib/Tmdb/Repository/TvEpisodeRepository.php @@ -66,6 +66,7 @@ public function load($tvShow, $season, $episode, array $parameters = array(), ar AppendToResponse::CREDITS, AppendToResponse::EXTERNAL_IDS, AppendToResponse::IMAGES, + AppendToResponse::CHANGES )) ); } diff --git a/lib/Tmdb/Repository/TvRepository.php b/lib/Tmdb/Repository/TvRepository.php index 2a3bfbe9..a11dc3da 100644 --- a/lib/Tmdb/Repository/TvRepository.php +++ b/lib/Tmdb/Repository/TvRepository.php @@ -45,7 +45,10 @@ public function load($id, array $parameters = array(), array $headers = array()) AppendToResponse::CREDITS, AppendToResponse::EXTERNAL_IDS, AppendToResponse::IMAGES, - AppendToResponse::TRANSLATIONS + AppendToResponse::TRANSLATIONS, + AppendToResponse::SIMILAR, + AppendToResponse::KEYWORDS, + AppendToResponse::CHANGES )) ); } @@ -216,4 +219,17 @@ public function getAiringToday(array $options = array(), array $headers = array( $this->getApi()->getAiringToday($options, $headers) ); } + + /** + * Get the latest tv-show. + * + * @param array $options + * @return null|\Tmdb\Model\AbstractModel + */ + public function getLatest(array $options = array()) + { + return $this->getFactory()->create( + $this->getApi()->getLatest($options) + ); + } } diff --git a/lib/Tmdb/Repository/TvSeasonRepository.php b/lib/Tmdb/Repository/TvSeasonRepository.php index d31cfc08..7937ea95 100644 --- a/lib/Tmdb/Repository/TvSeasonRepository.php +++ b/lib/Tmdb/Repository/TvSeasonRepository.php @@ -60,6 +60,7 @@ public function load($tvShow, $season, array $parameters = array(), array $heade AppendToResponse::CREDITS, AppendToResponse::EXTERNAL_IDS, AppendToResponse::IMAGES, + AppendToResponse::CHANGES )) ); } diff --git a/test/Tmdb/Tests/Api/MoviesTest.php b/test/Tmdb/Tests/Api/MoviesTest.php index cef6e85f..a0dd53c0 100644 --- a/test/Tmdb/Tests/Api/MoviesTest.php +++ b/test/Tmdb/Tests/Api/MoviesTest.php @@ -128,9 +128,9 @@ public function shouldGetSimilarMovies() $api = $this->getApiMock(); $api->expects($this->once()) ->method('get') - ->with('movie/' . self::MOVIE_ID . '/similar_movies'); + ->with('movie/' . self::MOVIE_ID . '/similar'); - $api->getSimilarMovies(self::MOVIE_ID); + $api->getSimilar(self::MOVIE_ID); } /** diff --git a/test/Tmdb/Tests/Api/TvTest.php b/test/Tmdb/Tests/Api/TvTest.php index 3fd637d8..b09068e8 100644 --- a/test/Tmdb/Tests/Api/TvTest.php +++ b/test/Tmdb/Tests/Api/TvTest.php @@ -146,6 +146,19 @@ public function shouldGetVideos() $api->getVideos(self::TV_ID); } + /** + * @test + */ + public function shouldGetLatest() + { + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('tv/latest'); + + $api->getLatest(); + } + protected function getApiClass() { return 'Tmdb\Api\Tv'; diff --git a/test/Tmdb/Tests/Factory/MovieFactoryTest.php b/test/Tmdb/Tests/Factory/MovieFactoryTest.php index 3cdf07e9..4380696e 100644 --- a/test/Tmdb/Tests/Factory/MovieFactoryTest.php +++ b/test/Tmdb/Tests/Factory/MovieFactoryTest.php @@ -102,7 +102,7 @@ public function shouldBeFunctional() $this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getKeywords()); $this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getLists()); $this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getReleases()); - $this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getSimilarMovies()); + $this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getSimilar()); $this->assertInstanceOf('Tmdb\Model\Common\GenericCollection', $this->movie->getTrailers()); } diff --git a/test/Tmdb/Tests/Model/MovieTest.php b/test/Tmdb/Tests/Model/MovieTest.php index 03d5099e..65f7c7f6 100644 --- a/test/Tmdb/Tests/Model/MovieTest.php +++ b/test/Tmdb/Tests/Model/MovieTest.php @@ -40,7 +40,7 @@ public function shouldConstructMovie() 'getKeywords' => 'Tmdb\Model\Common\GenericCollection', 'getLists' => 'Tmdb\Model\Common\GenericCollection', 'getReleases' => 'Tmdb\Model\Common\GenericCollection', - 'getSimilarMovies' => 'Tmdb\Model\Common\GenericCollection', + 'getSimilar' => 'Tmdb\Model\Common\GenericCollection', 'getTrailers' => 'Tmdb\Model\Common\GenericCollection', 'getTranslations' => 'Tmdb\Model\Common\GenericCollection', 'getVideos' => 'Tmdb\Model\Collection\Videos', diff --git a/test/Tmdb/Tests/Model/Query/ChangesQueryTest.php b/test/Tmdb/Tests/Model/Query/ChangesQueryTest.php index e0eebcd8..0daa89af 100644 --- a/test/Tmdb/Tests/Model/Query/ChangesQueryTest.php +++ b/test/Tmdb/Tests/Model/Query/ChangesQueryTest.php @@ -33,8 +33,8 @@ public function shouldCreateValidQuery() ->page(1) ; - $this->assertEquals($now->format('Y-m-d'), $query->get('from')); - $this->assertEquals($tomorrow->format('Y-m-d'), $query->get('to')); + $this->assertEquals($now->format('Y-m-d'), $query->get('start_date')); + $this->assertEquals($tomorrow->format('Y-m-d'), $query->get('end_date')); $this->assertEquals(1, $query->get('page')); } } diff --git a/test/Tmdb/Tests/Repository/MovieRepositoryTest.php b/test/Tmdb/Tests/Repository/MovieRepositoryTest.php index 150a989d..885a528d 100644 --- a/test/Tmdb/Tests/Repository/MovieRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/MovieRepositoryTest.php @@ -101,11 +101,11 @@ public function shouldGetTranslations() /** * @test */ - public function shouldGetSimilarMovies() + public function shouldGetSimilar() { $repository = $this->getRepositoryWithMockedHttpClient(); - $repository->getSimilarMovies(self::MOVIE_ID); + $repository->getSimilar(self::MOVIE_ID); } /** diff --git a/test/Tmdb/Tests/Repository/TvRepositoryTest.php b/test/Tmdb/Tests/Repository/TvRepositoryTest.php index 1f3356e6..aea32ed9 100644 --- a/test/Tmdb/Tests/Repository/TvRepositoryTest.php +++ b/test/Tmdb/Tests/Repository/TvRepositoryTest.php @@ -116,6 +116,16 @@ public function shouldGetVideos() $repository->getVideos(self::TV_ID); } + /** + * @test + */ + public function shouldGetLatestTvShow() + { + $repository = $this->getRepositoryWithMockedHttpClient(); + + $repository->getLatest(); + } + protected function getApiClass() { return 'Tmdb\Api\Tv'; diff --git a/test/Tmdb/Tests/Resources/tv/keywords.json b/test/Tmdb/Tests/Resources/tv/keywords.json new file mode 100644 index 00000000..cb2f8163 --- /dev/null +++ b/test/Tmdb/Tests/Resources/tv/keywords.json @@ -0,0 +1,17 @@ +{ + "id": 1396, + "results": [ + { + "id": 41525, + "name": "high school teacher" + }, + { + "id": 195308, + "name": "crystal method" + }, + { + "id": 2231, + "name": "drug dealer" + } + ] +} \ No newline at end of file