Example #1
0
 function setUp()
 {
     $this->container = new Container();
     $this->container->factory('imgurRequest', 'Imgur\\Request')->object('imgurCredentials', CachedCredentials::getInstance())->singleton('imgurAdapter', 'Imgur\\Adapter')->singleton('imgurImageRepo', 'Imgur\\ImageRepo')->singleton('imgurAlbumRepo', 'Imgur\\AlbumRepo');
     $this->cred = $this->container->lookup('imgurCredentials');
     $this->adapter = $this->container->lookup('imgurAdapter');
     $this->repo = $this->container->lookup('imgurAlbumRepo');
     $this->imageRepo = $this->container->lookup('imgurImageRepo');
 }
Example #2
0
 function setUp()
 {
     $this->container = new Container();
     $this->container->factory('imgurRequest', 'Imgur\\Request')->object('imgurCredentials', CachedCredentials::getInstance())->singleton('imgurAdapter', 'Imgur\\Adapter')->singleton('imgurImageRepo', 'Imgur\\ImageRepo');
     $this->cred = $this->container->lookup('imgurCredentials');
     $this->adapter = $this->container->lookup('imgurAdapter');
     $this->repo = $this->container->lookup('imgurImageRepo');
     $this->cred->clear();
     $this->cred->setClientId(getenv('IMGUR_CLIENT_ID'));
 }
Example #3
0
 function test_it_refreshes_access_token_before_model_request_if_needed()
 {
     if (getenv('IMGUR_SKIP_REMOTE')) {
         return;
     }
     $accessToken = getenv('IMGUR_ACCESS_TOKEN');
     $refreshToken = getenv('IMGUR_REFRESH_TOKEN');
     if (!$accessToken || !$refreshToken) {
         return;
     }
     $this->cred = CachedCredentials::getInstance();
     $this->adapter->imgurCredentials = $this->cred;
     $this->cred->setAccessTokenExpiry(0);
     $this->assertTrue($this->cred->hasAccessTokenExpired());
     $request = new Request();
     $request->setRoute('album/V9E5t');
     $album = $this->adapter->invoke($request);
     $this->assertEquals('V9E5t', $album['id']);
     $this->assertFalse($this->cred->hasAccessTokenExpired());
 }