Esempio n. 1
0
 /**
  * @dataProvider getTestData
  */
 public function testReturnCodes($code, $result)
 {
     $mock = new MockHandler([new HttpResponse($code)]);
     $handler = HandlerStack::create($mock);
     $guzzle = new GuzzleClient(['timeout' => 5, 'connection_timeout' => 2, 'handler' => $handler]);
     $client = new Client(new CredentialsProvider('api-key-123'), null, $guzzle);
     /** @var AuthorizationResponse $response */
     $response = $client->send(new Authorization('gavin', 'qwerty', 'test-tag'));
     $this->assertEquals($result, $response->isAuthorized());
 }
Esempio n. 2
0
 public function testSend()
 {
     $this->provider->shouldReceive('getKey')->andReturn('wiggle');
     /** @var RequestInterface $request */
     $request = m::mock(RequestInterface::class);
     $request->shouldReceive('addHeader')->withArgs(['x-api-key', 'wiggle']);
     $request->shouldReceive('addHeader')->withArgs(['content-type', 'application/json']);
     $request->shouldReceive('getHeaders')->andReturn(['x-api-key', 'wiggle']);
     $factory = m::mock(ResponseFactoryInterface::class);
     $factory->shouldReceive('create')->andReturn(m::mock(ResponseInterface::class));
     $request->shouldReceive('getResponseFactory')->andReturn($factory);
     $response = $this->client->send($request);
     $this->assertInstanceOf(ResponseInterface::class, $response);
 }