예제 #1
0
    public function testCheckIn()
    {
        $json = '{
  "watched_at": "2014-08-06T01:11:37.953Z",
  "sharing": {
    "facebook": true,
    "twitter": true,
    "tumblr": false
  },
  "movie": {
    "title": "Guardians of the Galaxy",
    "year": 2014,
    "ids": {
      "trakt": 28,
      "slug": "guardians-of-the-galaxy-2014",
      "imdb": "tt2015381",
      "tmdb": 118340
    }
  }
}';
        $client = Mockery::mock(stdClass::class . ", " . ClientInterface::class);
        $request = Mockery::mock(stdClass::class . ", " . RequestInterface::class);
        $response = Mockery::mock(stdClass::class . ", " . ResponseInterface::class);
        $client->shouldReceive("createRequest")->once()->andReturn($request);
        $response->shouldReceive("getStatusCode")->once()->andReturn(200);
        $response->shouldReceive("json")->once()->andReturn(json_decode($json));
        $client->shouldReceive("send")->once()->andReturn($response);
        $auth = mock_auth();
        $trakt = new Trakt($auth, $client);
        $checkIn = $trakt->checkIn;
        $this->assertInstanceOf("Wubs\\Trakt\\Api\\CheckIn", $checkIn);
        $response = $checkIn->create(get_token(), movie($client), "nooo way!", ['facebook' => false, 'twitter' => false, 'tumblr' => false], "1200", "blablabla", "1.1", $this->today->format("Y-m-d"));
        $this->assertInstanceOf("Wubs\\Trakt\\Response\\CheckIn", $response);
    }
 public function testGetCommentsFromEpisode()
 {
     $client = mock_client(200, '[
           {
             "id": 8,
             "parent_id": 0,
             "created_at": "2011-03-25T22:35:17.000Z",
             "comment": "Great episode!",
             "spoiler": false,
             "review": false,
             "replies": 1,
             "user_rating": 8,
             "user": {
               "username": "******",
               "private": false,
               "name": "Sean Rudford",
               "vip": true,
               "vip_ep": false
             }
           }
         ]');
     $auth = mock_auth();
     $trakt = new Trakt($auth, $client);
     $comments = $trakt->episodes->comments(8, 2, 1);
     $this->assertInstanceOf(Collection::class, $comments);
 }
 public function testAllShows()
 {
     $client = mock_client(200, "[]");
     $auth = mock_auth();
     $trakt = new Trakt($auth, $client);
     $res = $trakt->calendars->shows($this->today, 7);
     $this->assertInternalType("object", $res);
 }
 public function testCheckOutFromGlobal()
 {
     $client = Mockery::mock(ClientInterface::class);
     $request = Mockery::mock(RequestInterface::class);
     $response = Mockery::mock(ResponseInterface::class);
     $client->shouldReceive("createRequest")->andReturn($request);
     $client->shouldReceive("send")->once()->andReturn($response);
     $response->shouldReceive("getStatusCode")->twice()->andReturn(204);
     $auth = mock_auth();
     $trakt = new Trakt($auth, $client);
     $this->assertTrue($trakt->checkIn->delete(get_token()));
 }
    public function testCheckInEpisode()
    {
        $client = mock_client(201, '{
  "episode": {
    "ids": {
      "trakt": 16
    }
  },
  "sharing": {
    "facebook": true,
    "twitter": true,
    "tumblr": false
  },
  "message": "I\'m the one who knocks!",
  "app_version": "1.0",
  "app_date": "2014-09-22"
}');
        $auth = mock_auth();
        $trakt = new Trakt($auth, $client);
        /** @var CheckIn $response */
        $response = $trakt->checkIn->create(get_token(), episode($client), "Whoooot! I like this so much!");
        $this->assertInstanceOf(CheckIn::class, $response);
        $this->assertInternalType("object", $response->media);
    }
 public function testWatching()
 {
     $client = mock_client(200, "[]");
     $auth = mock_auth();
     $trakt = new Trakt($auth, $client);
     $res = $trakt->movies->watching($this->id);
     $this->assertInternalType("object", $res);
 }
예제 #7
0
    public function testSearchMovieByIdWithAuthToken()
    {
        $client = mock_client(200, '[
  {
    "type": "movie",
    "score": null,
    "movie": {
      "title": "The Avengers",
      "overview": "When an unexpected enemy emerges and threatens global safety and security, Nick Fury, director of the international peacekeeping agency known as S.H.I.E.L.D., finds himself in need of a team to pull the world back from the brink of disaster. Spanning the globe, a daring recruitment effort begins!",
      "year": 2012,
      "images": {
        "poster": {
          "full": "https://walter.trakt.us/images/movies/000/000/012/posters/original/293ce7103a.jpg?1406080484",
          "medium": "https://walter.trakt.us/images/movies/000/000/012/posters/medium/293ce7103a.jpg?1406080484",
          "thumb": "https://walter.trakt.us/images/movies/000/000/012/posters/thumb/293ce7103a.jpg?1406080484"
        },
        "fanart": {
          "full": "https://walter.trakt.us/images/movies/000/000/012/fanarts/original/7d93500475.jpg?1406080485",
          "medium": "https://walter.trakt.us/images/movies/000/000/012/fanarts/medium/7d93500475.jpg?1406080485",
          "thumb": "https://walter.trakt.us/images/movies/000/000/012/fanarts/thumb/7d93500475.jpg?1406080485"
        }
      },
      "ids": {
        "trakt": 12,
        "slug": "the-avengers-2012",
        "imdb": "tt0848228",
        "tmdb": 24428
      }
    }
  }
]');
        $auth = mock_auth();
        $trakt = new Trakt($auth, $client);
        $result = $trakt->search->byId('trakt-movie', 12, get_token());
        $this->assertInstanceOf(Collection::class, $result);
        $this->assertInternalType("object", $result->first());
        $this->assertInstanceOf(Movie::class, $result->first());
    }