Exemplo n.º 1
0
 /**
  * @test
  */
 public function shouldSendPostRequest()
 {
     $url = "http://foobar";
     $data = array("foo" => "bar");
     $stream = Mockery::mock('Psr\\Http\\Message\\StreamInterface');
     $stream->shouldReceive("getContents")->once()->with()->andReturn(json_encode($data));
     $jsonResponse = Mockery::mock('\\Psr\\Http\\Message\\ResponseInterface');
     $jsonResponse->shouldReceive("getBody")->once()->andReturn($stream);
     $this->guzzleClient->shouldReceive("request")->once()->andReturn($jsonResponse);
     $this->requestInvoker->post($url, $data);
 }
 /**
  * @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);
 }