コード例 #1
0
 public function testGetTraktAuthorizationUrl()
 {
     $clientId = get_client_id();
     $provider = new TraktProvider($clientId, getenv("CLIENT_SECRET"), getenv("TRAKT_REDIRECT_URI"));
     $authUrl = $provider->getAuthorizationUrl();
     $this->assertContains("https://trakt.tv/oauth/authorize", $authUrl);
     $this->assertContains(get_client_id(), $authUrl);
 }
コード例 #2
0
 public function testOAuthFlowAuthorization()
 {
     $provider = Mockery::mock(TraktProvider::class);
     $provider->shouldReceive("authorize")->once();
     $provider->shouldReceive("getClientId")->once()->andReturn(get_client_id());
     $auth = new Auth($provider);
     $trakt = new Trakt($auth, TraktHttpClient::make());
     $trakt->auth->authorize(getenv("CLIENT_ID"), getenv("CLIENT_SECRET"), "uri");
 }
コード例 #3
0
 public function testParsesResponseToListOfMovies()
 {
     $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
             }
           }
         }
       ]
     }';
     $client = Mockery::mock(stdClass::class . ", " . ClientInterface::class);
     $response = Mockery::mock(stdClass::class . ", " . ResponseInterface::class);
     //        $client->shouldReceive("createRequest")->once()->andReturn($request);
     $response->shouldReceive("json")->once()->andReturn(json_decode($json));
     $client->shouldReceive("send")->andReturn($response);
     $moviesHandler = new MoviesHandler();
     $moviesHandler->setClientId(get_client_id());
     $moviesHandler->setToken(get_token());
     $handled = $moviesHandler->handle($response, $client);
     $this->assertInstanceOf(Calendar::class, $handled);
     $this->assertInstanceOf(Day::class, $handled->days[0]);
 }
コード例 #4
0
 public function testOnlyPassRequestParameters()
 {
     $client = Mockery::mock(ClientInterface::class);
     $request = Mockery::mock(RequestInterface::class);
     $response = Mockery::mock(ResponseInterface::class);
     $client->shouldReceive("createRequest")->once()->andReturn($request);
     $response->shouldReceive("getStatusCode")->once()->andReturn(200);
     $response->shouldReceive("json")->once()->andReturn([]);
     $client->shouldReceive("send")->andReturn($response);
     $response = (new Movies(get_token(), Carbon::now(), 20))->make(get_client_id(), $client);
     $this->assertInternalType("object", $response);
 }
コード例 #5
0
 public function testCanSetExtendedLevelOnEndpoint()
 {
     $endpoint = new Calendars\My(get_client_id(), mock_client(200, '[
                 {
                     "episode":{"images": ""}
                 }
             ]'));
     $endpoint->withImages()->withFull();
     $calendar = $endpoint->shows(get_token());
     $first = $calendar->first();
     $this->assertObjectHasAttribute("images", $first->episode);
 }
コード例 #6
0
 public function testCheckOut()
 {
     $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")->twice()->andReturn(204);
     $client->shouldReceive("send")->andReturn($response);
     $id = get_client_id();
     $token = get_token();
     $response = (new Delete($token))->make($id, $client);
     $this->assertTrue($response);
 }
コード例 #7
0
 public function testCanPaginatePaginatableMethod()
 {
     $movies = new Collected();
     $movies->setPage(2);
     $movies->setLimit(15);
     $movies->setResponseHandler(new PaginationTestResponseHandler());
     /** @var ResponseInterface $response */
     $response = $movies->make(get_client_id(), TraktHttpClient::make());
     $url = $response->getEffectiveUrl();
     $movies = collect($response->json(['object' => true]));
     $this->assertEquals('2', $response->getHeader('X-Pagination-Page'));
     $this->assertEquals('15', $response->getHeader('X-Pagination-Limit'));
     $this->assertContains("limit=15", $url);
     $this->assertContains("page=2", $url);
     $this->assertCount(15, $movies);
 }
コード例 #8
0
   public function testCanMakeMovieObjectFromBasicResult()
   {
       $json = '{
   "title": "The Dark Knight",
   "year": 2008,
   "ids": {
     "trakt": 16,
     "slug": "the-dark-knight-2008",
     "imdb": "tt0468569",
     "tmdb": 155
   }
 }';
       $json = json_decode($json);
       $client = Mockery::mock(ClientInterface::class);
       $movie = new Movie($json, get_client_id(), get_token(), $client);
       $this->assertEquals("The Dark Knight", $movie->title);
   }
コード例 #9
0
    public function testCanProcessSearchResult()
    {
        $json = '{
  "type": "show",
  "score": 19.533358,
  "show": {
    "title": "Breaking Bad",
    "overview": "Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. Set and produced in Albuquerque, New Mexico, Breaking Bad is the story of Walter White, a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series. He turns to a life of crime, producing and selling methamphetamine, in order to secure his family financial future before he dies, teaming with his former student, Jesse Pinkman. Heavily serialized, the series is known for positioning its characters in seemingly inextricable corners and has been labeled a contemporary western by its creator.",
    "year": 2008,
    "images": {
      "poster": {
        "full": "https://walter.trakt.us/images/shows/000/000/001/posters/original/7217fe0ea7.jpg?1412271410",
        "medium": "https://walter.trakt.us/images/shows/000/000/001/posters/medium/7217fe0ea7.jpg?1412271410",
        "thumb": "https://walter.trakt.us/images/shows/000/000/001/posters/thumb/7217fe0ea7.jpg?1412271410"
      },
      "fanart": {
        "full": "https://walter.trakt.us/images/shows/000/000/001/fanarts/original/2fb47044fd.jpg?1412271412",
        "medium": "https://walter.trakt.us/images/shows/000/000/001/fanarts/medium/2fb47044fd.jpg?1412271412",
        "thumb": "https://walter.trakt.us/images/shows/000/000/001/fanarts/thumb/2fb47044fd.jpg?1412271412"
      }
    },
    "ids": {
      "trakt": 1,
      "slug": "breaking-bad",
      "tvdb": 81189,
      "imdb": "tt0903747",
      "tmdb": 1396,
      "tvrage": 18164
    }
  }
}';
        $json = json_decode($json);
        $client = Mockery::mock(ClientInterface::class);
        $show = new Show($json, get_client_id(), get_token(), $client);
        $this->assertEquals("Breaking Bad", $show->title);
    }
コード例 #10
0
 /**
  * @depends testGeneratesClassFile
  */
 public function testClassCanBeInitiated()
 {
     $client = Mockery::mock(ClientInterface::class);
     $class = new $this->namespace(get_client_id(), $client);
     $this->assertInstanceOf($this->namespace, $class);
 }
コード例 #11
0
ファイル: showpage.php プロジェクト: bimbam123/quexf
 *	
 *	queXF is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *	
 *	You should have received a copy of the GNU General Public License
 *	along with queXF; if not, write to the Free Software
 *	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */
include "../config.inc.php";
include "../db.inc.php";
include "../functions/functions.image.php";
include "../functions/functions.client.php";
$cid = get_client_id();
if (isset($_GET['pid']) && $cid != false) {
    global $db;
    $pid = intval($_GET['pid']);
    if (isset($_GET['fid'])) {
        $fid = intval($_GET['fid']);
        $sql = "SELECT fp.image\n\t\t\tFROM formpages as fp, clientquestionnaire as cq, forms as f\n\t\t\tWHERE fp.pid = {$pid} AND fp.fid = {$fid}\n\t\t\tAND cq.cid = '{$cid}' AND cq.qid = f.qid AND f.fid = fp.fid";
        $row = $db->GetRow($sql);
        if (empty($row)) {
            exit;
        }
        $im = imagecreatefromstring($row['image']);
        $width = imagesx($im);
        $height = imagesy($im);
        $newwidth = DISPLAY_PAGE_WIDTH;
        $newheight = round($height * (DISPLAY_PAGE_WIDTH / $width));
コード例 #12
0
 public function testRequestWithoutToken()
 {
     $response = (new History('megawubs', Type::movies()))->make(get_client_id(), TraktHttpClient::make());
     $this->assertInternalType("object", $response);
 }
コード例 #13
0
    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);
    }
コード例 #14
0
function mock_auth()
{
    $provider = Mockery::mock(TraktProvider::class);
    $provider->shouldReceive("getClientId")->once()->andReturn(get_client_id());
    return new Auth($provider);
}
コード例 #15
0
 public function testPropertiesOfRequestObjectAreRequestObjects()
 {
     $auth = new Auth(new TraktProvider(get_client_id(), get_client_secret(), get_redirect_url()));
     $trakt = new Trakt($auth);
     $this->assertInstanceOf(Followers::class, $trakt->users->followers);
 }