/** * @test */ public function shouldRetrieveTokenAndCacheIt() { $credentials = new Credentials("id", "secret", "username", "password"); $cacheKey = (string) $credentials; $token = new AccessToken("foo", "http://", "http://foo/some-id", "bar", "1457566074818", "foobar"); $this->tokenProvider->shouldReceive("getToken")->once()->with($credentials)->andReturn($token); $this->arrayCache->shouldReceive("contains")->once()->with($cacheKey)->andReturn(false); $this->arrayCache->shouldReceive("save")->once()->with($cacheKey, $token); $this->arrayCache->shouldReceive("fetch")->once()->with((string) $credentials)->andReturn($token); $this->cachingTokenProvider->getToken($credentials); }
/** * @test */ public function shouldRetrieveAccessToken() { $credentials = new Credentials("id", "secret", "username", "password"); $this->genericClient->shouldReceive("post")->once()->andReturn(json_encode(array("access_token" => "foo", "instance_url" => "https://", "id" => "https://foo/some-id", "token_type" => "bar", "issued_at" => "1457566074818", "signature" => "foobar"))); $this->authClient->getToken($credentials); }