コード例 #1
0
ファイル: Day.php プロジェクト: ValentinGot/trakt-api-wrapper
 /**
  * @param $items
  */
 private function setReleases($items)
 {
     foreach ($items as $item) {
         if ($this->type == Type::movie()) {
             $this->releases[] = new Movie($item, $this->id, $this->token, $this->client);
         }
         if ($this->type == Type::show()) {
             $this->releases[] = new Show($item, $this->id, $this->token, $this->client);
         }
     }
 }
コード例 #2
0
    public function testSearchMovieWithToken()
    {
        $client = mock_client(200, '[
  {
    "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
      }
    }
  }
]');
        $auth = mock_auth();
        $trakt = new Trakt($auth, $client);
        $search = $trakt->search->byText("Batman", Type::movie(), 2011, get_token());
        $this->assertInstanceOf(Collection::class, $search);
        $this->assertInstanceOf(Movie::class, $search->first());
    }
コード例 #3
0
 /**
  * @param $json
  */
 private function getMedia($json)
 {
     if (property_exists($json, "type")) {
         if ($this instanceof Movie) {
             $this->type = Type::movie();
             return $json->movie;
         }
         if ($this instanceof Show) {
             $this->type = Type::show();
             return $json->show;
         }
         if ($this instanceof Person) {
             $this->type = Type::person();
             return $json->person;
         }
     }
     return $this->json;
 }
コード例 #4
0
 /**
  * @param ResponseInterface $response
  * @param ClientInterface $client
  * @return Calendar
  */
 public function handle(ResponseInterface $response, ClientInterface $client)
 {
     $json = $this->getJson($response);
     return new Calendar($json, Type::movie(), $this->getClientId(), $this->getToken(), $client);
 }
コード例 #5
0
 /**
  * @param $item
  * @return bool
  */
 protected function isMovie($item)
 {
     return $item->type == Type::movie();
 }
コード例 #6
0
 public function testParseMultipleReleaseDates()
 {
     $json = '{
           "2014-08-01": [
             {
               "movie": {
                 "title": "Guardians of the Galaxy",
                 "year": 2014,
                 "ids": {
                   "trakt": 28,
                   "slug": "guardians-of-the-galaxy-2014",
                   "imdb": "tt2015381",
                   "tmdb": 118340
                 }
               }
             },
             {
               "movie": {
                 "title": "Get On Up",
                 "year": 2014,
                 "ids": {
                   "trakt": 29,
                   "slug": "get-on-up-2014",
                   "imdb": "tt2473602",
                   "tmdb": 239566
                 }
               }
             }
           ],
           "2014-08-08": [
             {
               "movie": {
                 "title": "Teenage Mutant Ninja Turtles",
                 "year": 2014,
                 "ids": {
                   "trakt": 30,
                   "slug": "teenage-mutant-ninja-turtles-2014",
                   "imdb": "tt1291150",
                   "tmdb": 98566
                 }
               }
             }
           ]
         }';
     $response = new TestResponse($json);
     $json = $response->json(["object" => true]);
     $days = [];
     $client = Mockery::mock(stdClass::class . ", " . ClientInterface::class);
     foreach ($json as $date => $movies) {
         $days[] = new Day($date, $movies, Type::movie(), get_client_id(), get_token(), $client);
     }
     $this->assertInstanceOf(Day::class, $days[0]);
     $this->assertCount(2, $days);
     $this->assertInstanceOf(Media::class, $days[0]->releases[0]);
 }
コード例 #7
0
 public function testSearchMovie()
 {
     $request = new ByText("guardians of the galaxy", Type::movie(), "2014");
     $this->assertEquals(RequestType::GET, $request->getRequestType());
     $this->assertEquals("search", $request->getUrl());
 }