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 testSettingTokenAndGettingProperties() { $this->ifs->setToken(new Token(array('access_token' => 'foo', 'refresh_token' => 'bar', 'expires_in' => 1, 'key' => 'value'))); $this->assertEquals('foo', $this->ifs->getToken()->getAccessToken()); $this->assertEquals('bar', $this->ifs->getToken()->getRefreshToken()); $this->assertEquals(time() + 1, $this->ifs->getToken()->getEndOfLife()); $extra = $this->ifs->getToken()->getExtraInfo(); $this->assertEquals('value', $extra['key']); }
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()); }