public function getToken($createIfNeeded = true)
{
if ($createIfNeeded && !$this->hasToken()) {
$response = $this->createToken()->send();
if ($response->isSuccessful()) {
$data = $response->getData();
if (isset($data['access_token'])) {
$this->setToken($data['access_token']);
$this->setTokenExpires(time() + $data['expires_in']);
}
}
}
return $this->getParameter('token');
}
public function testBearerTokenExpires() { $this->setMockHttpResponse('RestTokenSuccess.txt'); $this->gateway->setToken('MYTOKEN'); $this->gateway->setTokenExpires(time() - 60); $this->assertFalse($this->gateway->hasToken()); $this->assertEquals('A015GQlKQ6uCRzLHSGRliANi59BHw6egNVKEWRnxvTwvLr0', $this->gateway->getToken()); }