public static function setUpBeforeClass() { self::$client = new Client(); $tokenInfoStream = Stream::factory(JsonLoader::getTokenInfoJson()); $accessTokenStream = Stream::factory(JsonLoader::getAccessTokenJson()); $mock = new Mock([new Response(200, array(), $tokenInfoStream), new Response(200, array(), $accessTokenStream)]); self::$client->getEmitter()->attach($mock); }
public function testGetAccessToken() { $curlResponse = CurlResponse::create(JsonLoader::getAccessTokenJson(), array('http_code' => 200)); $this->restClient->expects($this->once())->method('post')->with()->will($this->returnValue($curlResponse)); $token = $this->ctctOAuth2->getAccessToken("fakeCode"); $this->assertEquals("v6574b42-a5bc-4574-a87f-5c9d1202e316", $token['access_token']); $this->assertEquals("308874923", $token['expires_in']); $this->assertEquals("Bearer", $token['token_type']); }