/**
  * Set up.
  */
 public function setUp()
 {
     $responseArray = [];
     $this->clientFactory = new ApiClientFactory();
     $this->client = $this->clientFactory->create(self::BASE_URL);
     $mockResponse = new \GuzzleHttp\Subscriber\Mock([new GuzzleHttp\Message\Response(200, [], GuzzleHttp\Stream\Stream::factory(json_encode($responseArray)))]);
     $guzzle = $this->client->getHttpClient();
     $guzzle->getEmitter()->attach($mockResponse);
 }
Exemplo n.º 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);
 }