Ejemplo n.º 1
0
 public function testAccessTokenSetOnCacheMiss()
 {
     $requester = new Requester($this->mockClientFactory, $this->clientId, $this->clientSecret, $this->mockCache, null);
     $this->mockCache->shouldReceive('has')->once()->andReturn(false);
     $this->mockCache->shouldReceive('put')->once()->with(Requester::ACCESS_TOKEN_CACHE_KEY, self::MOCK_ACCESS_TOKEN, Requester::ACCESS_TOKEN_CACHE_TTL);
     $mockResponse = $this->getMockAccessTokenResponse(array('access_token' => self::MOCK_ACCESS_TOKEN));
     $this->mockGuzzle->shouldReceive('post')->with('/v1/oauth/token', m::any())->once()->andReturn($mockResponse);
     $token = $requester->getAccessToken();
     $this->assertEquals(self::MOCK_ACCESS_TOKEN, $token);
 }
Ejemplo n.º 2
0
 /**
  * Returns an access token if available, otherwise false.
  * Note: tokens last for 1 hour. It's up to the client to
  * cache this token if needed
  *
  * @return bool|string
  * @throws RequestException|LogicException|ParseException
  */
 public function getAccessToken()
 {
     return $this->requester->getAccessToken();
 }