/** * @param string $method * @param array $arguments * @return ResponseInterface * @throws RequestException When an error is encountered */ public function request($method, $arguments) { $options['query'] = array_merge($this->options, $arguments); $options['cert'] = $this->certificate; $response = $this->client->get($this->getEndpoint($method), $options); return $this->factory->getResponse($response); }
public function testError403() { $response = m::mock(GuzzleResponseInterface::class); $response->shouldReceive('getBody')->andReturn($this->tostream(TestFixtures::getFixture('failure_403'))); $gigyaResponse = $this->factory->getResponse($response); static::assertInstanceOf('Graze\\Gigya\\Response\\Response', $gigyaResponse); static::assertEquals(403, $gigyaResponse->getStatusCode()); static::assertEquals(403005, $gigyaResponse->getErrorCode()); static::assertEquals('Forbidden', $gigyaResponse->getStatusReason()); static::assertEquals('Unauthorized user', $gigyaResponse->getErrorMessage()); static::assertEquals('The user billyBob cannot login', $gigyaResponse->getErrorDetails()); }
public function testNoBody() { $response = m::mock('GuzzleHttp\\Message\\ResponseInterface'); $response->shouldReceive('getBody')->andReturn(''); $this->validator->shouldReceive('assert')->with($response)->andThrow(new UnknownResponseException($response)); static::setExpectedException('Graze\\Gigya\\Exceptions\\UnknownResponseException', 'The contents of the response could not be determined'); $this->factory->getResponse($response); }
/** * @dataProvider clientCallDataProvider * @param $namespace * @param $method * @param $expectedUri */ public function testClientCalls($namespace, $method, $expectedUri) { $client = $this->createClient(); $response = m::mock('GuzzleHttp\\Message\\ResponseInterface'); $response->shouldReceive('getBody')->andReturn(TestFixtures::getFixture('accounts.getAccountInfo')); $this->guzzleClient->shouldReceive('get')->with($expectedUri, ['query' => ['apiKey' => 'key', 'secret' => 'secret', 'params' => 'passedThrough'], 'cert' => $this->certPath])->andReturn($response); $gigyaResponse = m::mock('Graze\\Gigya\\Response\\ResponseInterface'); $this->factory->shouldReceive('getResponse')->with($response)->andReturn($gigyaResponse); $result = $client->{$namespace}()->{$method}(['params' => 'passedThrough']); static::assertSame($gigyaResponse, $result); }