public function testSetBaseUri()
 {
     $guzzle = GuzzleFactory::createClient('http://fail-base-uri.no');
     $goodUri = 'http://realbaseuri.yes';
     $guzzle->setBaseUri($goodUri);
     $this->assertEquals($goodUri, $guzzle->getBaseUri());
 }
 public function testCreateGuzzleReturnsInitializedInstanceOfAbstractGuzzle()
 {
     $baseUri = 'http://my-base-url.tld';
     $guzzle = GuzzleFactory::createClient($baseUri);
     $this->assertInstanceOf('CanalTP\\AbstractGuzzle\\Guzzle', $guzzle);
     $this->assertEquals($baseUri, $guzzle->getBaseUri());
 }
 /**
  * @param array $responseCollection
  * @return \CanalTP\AbstractGuzzle\Guzzle
  */
 public function getMock(array $responseCollection)
 {
     $plugin = new MockPlugin();
     foreach ($responseCollection as $response) {
         if ($response instanceof Psr7Response) {
             $response = new Response($response->getStatusCode(), $response->getHeaders(), $response->getBody());
         }
         $plugin->addResponse($response);
     }
     $client = GuzzleFactory::createClient('');
     $client->addSubscriber($plugin);
     return $client;
 }
 /**
  * @param Response[] $responseCollection
  * @return \CanalTP\AbstractGuzzle\Guzzle
  */
 public function getMock(array $responseCollection)
 {
     $version5ResponseCollection = [];
     $client = GuzzleFactory::createClient('');
     foreach ($responseCollection as $response) {
         if ($response instanceof Psr7Response) {
             $version5ResponseCollection[] = new Response($response->getStatusCode(), $response->getHeaders(), Stream::factory($response->getBody()->getContents()));
         } else {
             $version5ResponseCollection[] = new Response();
         }
     }
     $mock = new Mock($version5ResponseCollection);
     $client->getEmitter()->attach($mock);
     return $client;
 }
 /**
  * Guzzle6Mock .
  *
  * @param array $responseCollection new Response(200, ['X-Foo' => 'Bar']),
  * new Response(202, ['Content-Length' => 0]),
  * new RequestException("Error Communicating with Server", new Request('GET', 'test'))
  * @return \CanalTP\AbstractGuzzle\Guzzle
  */
 public function getMock(array $responseCollection)
 {
     $mock = new MockHandler($responseCollection);
     $handler = HandlerStack::create($mock);
     return GuzzleFactory::createClient('', ['handler' => $handler]);
 }