public function setUp() { $token = new \Infusionsoft\Token(['access_token' => 'foo', 'expires_in' => 3600]); $this->ifs = new Infusionsoft(); $this->ifs->setToken($token); $this->endpoint = 'https://api.infusionsoft.com/crm/xmlrpc/v1?access_token=foo'; $this->transport = test::double('fXmlRpc\\Transport\\GuzzleBridge', ['send' => true]); }
public function testRequestingAccessTokenSetsAccessToken() { $client = m::mock('Infusionsoft\\Http\\GuzzleHttpClient'); $client->shouldReceive('request')->once()->with('POST', 'https://api.infusionsoft.com/token', ['body' => array('client_id' => 'foo', 'client_secret' => 'bar', 'code' => 'code', 'grant_type' => 'authorization_code', 'redirect_uri' => 'baz')])->andReturn(array('access_token' => 'access_token')); $this->ifs->setClientId('foo'); $this->ifs->setClientSecret('bar'); $this->ifs->setRedirectUri('baz'); $this->ifs->setHttpClient($client); $this->ifs->requestAccessToken('code'); $this->assertEquals('access_token', $this->ifs->getToken()->getAccessToken()); }
public function testIsTokenExpired() { //no token is set so it should return true $this->assertTrue($this->ifs->isTokenExpired()); //token is set and still not expired $token = new Token(array('access_token' => '', 'refresh_token' => '', 'expires_in' => 5)); $this->ifs->setToken($token); $this->assertFalse($this->ifs->isTokenExpired()); //token is set but expired $token = new Token(array('access_token' => '', 'refresh_token' => '', 'expires_in' => -5)); $this->ifs->setToken($token); $this->assertTrue($this->ifs->isTokenExpired()); }