public function testCanMakeMovieObjectFromSearchResult() { $json = '{ "type": "movie", "score": 26.019499, "movie": { "title": "Batman Begins", "overview": "Driven by tragedy, billionaire Bruce Wayne dedicates his life to uncovering and defeating the corruption that plagues his home, Gotham City. Unable to work within the system, he instead creates a new identity, a symbol of fear for the criminal underworld - The Batman.", "year": 2005, "images": { "poster": { "full": "https://walter.trakt.us/images/movies/000/000/001/posters/original/9634ffd477.jpg?1406080393", "medium": "https://walter.trakt.us/images/movies/000/000/001/posters/medium/9634ffd477.jpg?1406080393", "thumb": "https://walter.trakt.us/images/movies/000/000/001/posters/thumb/9634ffd477.jpg?1406080393" }, "fanart": { "full": "https://walter.trakt.us/images/movies/000/000/001/fanarts/original/7da8cfbe9e.jpg?1406080393", "medium": "https://walter.trakt.us/images/movies/000/000/001/fanarts/medium/7da8cfbe9e.jpg?1406080393", "thumb": "https://walter.trakt.us/images/movies/000/000/001/fanarts/thumb/7da8cfbe9e.jpg?1406080393" } }, "ids": { "trakt": 1, "slug": "batman-begins-2005", "imdb": "tt0372784", "tmdb": 272 } } }'; $clientId = get_client_id(); $token = get_token(); $mockResponse = new TestResponse($json); $client = Mockery::mock(ClientInterface::class); $movie = new Movie($mockResponse->json(['object' => true]), $clientId, $token, $client); $this->assertInstanceOf("Wubs\\Trakt\\Media\\Movie", $movie); $this->assertEquals(26.019499, $movie->score); $this->assertEquals("Batman Begins", $movie->title); }
public function testCanHandleResponseWithShows() { $json = '{ "2014-07-14": [ { "airs_at": "2014-07-14T01:00:00.000Z", "episode": { "season": 7, "number": 4, "title": "Death is Not the End", "ids": { "trakt": 443, "tvdb": 4851180, "imdb": "tt3500614", "tmdb": 988123, "tvrage": null } }, "show": { "title": "True Blood", "year": 2008, "ids": { "trakt": 5, "slug": "true-blood", "tvdb": 82283, "imdb": "tt0844441", "tmdb": 10545, "tvrage": 12662 } } }, { "airs_at": "2014-07-14T02:00:00.000Z", "episode": { "season": 1, "number": 3, "title": "Two Boats and a Helicopter", "ids": { "trakt": 499, "tvdb": 4854797, "imdb": "tt3631218", "tmdb": 988346, "tvrage": null } }, "show": { "title": "The Leftovers", "year": 2014, "ids": { "trakt": 7, "slug": "the-leftovers", "tvdb": 269689, "imdb": "tt2699128", "tmdb": 54344, "tvrage": null } } } ], "2014-07-21": [ { "airs_at": "2014-07-21T01:00:00.000Z", "episode": { "season": 7, "number": 5, "title": "Return to Oz", "ids": { "trakt": 444, "tvdb": 4851181, "imdb": "tt3500616", "tmdb": 988124, "tvrage": null } }, "show": { "title": "True Blood", "year": 2008, "ids": { "trakt": 5, "slug": "true-blood", "tvdb": 82283, "imdb": "tt0844441", "tmdb": 10545, "tvrage": 12662 } } }, { "airs_at": "2014-07-21T02:00:00.000Z", "episode": { "season": 1, "number": 4, "title": "B.J. and the A.C.", "ids": { "trakt": 500, "tvdb": 4854798, "imdb": "tt3594942", "tmdb": 988347, "tvrage": null } }, "show": { "title": "The Leftovers", "year": 2014, "ids": { "trakt": 7, "slug": "the-leftovers", "tvdb": 269689, "imdb": "tt2699128", "tmdb": 54344, "tvrage": null } } } ] }'; $mockResponse = new TestResponse($json); $json = $mockResponse->json(['object' => true]); $days = []; $client = Mockery::mock(stdClass::class . ", " . ClientInterface::class); foreach ($json as $date => $shows) { $days[] = new Day($date, $shows, Type::show(), get_client_id(), get_token(), $client); } $this->assertInstanceOf(Show::class, $days[0]->releases[0]); $this->assertCount(2, $days); }