public function testRequest()
 {
     $response = new GuzzleHttp\Psr7\Response(200, ['X-Foo' => 'Bar'], GuzzleHttp\Psr7\stream_for('foo'));
     $mockedHandler = new GuzzleHttp\Handler\MockHandler([$response]);
     $handlerStack = \GuzzleHttp\HandlerStack::create($mockedHandler);
     $client = new LeagueWrap\Client();
     $client->baseUrl('http://google.com');
     $client->setTimeout(10);
     $client->addMock($handlerStack);
     $response = $client->request('', []);
     $this->assertEquals('foo', $response);
 }
示例#2
0
 public function testRequest()
 {
     $response = new GuzzleHttp\Message\Response(200, ['X-Foo' => 'Bar']);
     $response->setBody(GuzzleHttp\Stream\Stream::factory('foo'));
     $mock = new GuzzleHttp\Subscriber\Mock([$response]);
     $client = new LeagueWrap\Client();
     $client->baseUrl('http://google.com');
     $client->setTimeout(10);
     $client->addMock($mock);
     $response = $client->request('', []);
     $this->assertEquals('foo', $response);
 }
示例#3
0
 public function testRequest()
 {
     $response = new GuzzleHttp\Psr7\Response(200, ['X-Foo' => 'Bar'], GuzzleHttp\Psr7\stream_for('foo'));
     $mockedHandler = new GuzzleHttp\Handler\MockHandler([$response]);
     $handlerStack = \GuzzleHttp\HandlerStack::create($mockedHandler);
     $client = new LeagueWrap\Client();
     $client->baseUrl('http://google.com');
     $client->setTimeout(10);
     $client->addMock($handlerStack);
     $response = $client->request('', []);
     $this->assertEquals('foo', $response);
     $this->assertEquals(200, $response->getCode());
     $this->assertTrue($response->hasHeader('X-Foo'));
     $this->assertFalse($response->hasHeader('Missing-Header'));
     $this->assertEquals('Bar', $response->getHeader('X-Foo'));
     $this->assertNull($response->getHeader('that does not exists'));
     $headers = $response->getHeaders();
     $this->assertArrayHasKey('X-Foo', $headers);
     $this->assertCount(1, $headers);
     $this->assertEquals('Bar', $headers['X-Foo']);
 }