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");
 }
 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);
 }
 public function testRequestWithoutToken()
 {
     $response = (new History('megawubs', Type::movies()))->make(get_client_id(), TraktHttpClient::make());
     $this->assertInternalType("object", $response);
 }
<?php

/**
 * Created by PhpStorm.
 * User: bwubs
 * Date: 25/02/15
 * Time: 14:22
 */
use Dotenv\Dotenv;
use Wubs\Trakt\Auth\Auth;
use Wubs\Trakt\Auth\TraktProvider;
use Wubs\Trakt\Trakt;
use Wubs\Trakt\TraktHttpClient;
require '../vendor/autoload.php';
session_start();
(new Dotenv(__DIR__ . "/../"))->load();
$provider = new TraktProvider(getenv("CLIENT_ID"), getenv("CLIENT_SECRET"), getenv("TRAKT_REDIRECT_URI"));
$auth = new Auth($provider);
$trakt = new Trakt($auth, TraktHttpClient::make());
$trakt->auth->authorize();
//after authorization the user will be redirected to the page where you preform a token
// request. see token.php
 /**
  * @param Auth $auth
  * @param ClientInterface $client
  */
 public function __construct(Auth $auth, ClientInterface $client = null)
 {
     $this->client = $client;
     if ($client == null) {
         $this->client = TraktHttpClient::make();
     }
     $this->auth = $auth;
     $this->createWrappers();
 }