public function testExceptionInvalidUrl()
 {
     try {
         $relativeUri = sprintf('/%s/%s/foo', Client::API_VERSION, self::MERCHANT_ID);
         $this->defaultCommunicator->get($this->defaultResponseClassMap, $relativeUri);
     } catch (InvalidResponseException $e) {
         $this->assertEquals(404, $e->getResponse()->getHttpStatusCode());
         return;
     }
     $this->fail('an expected exception has not been raised');
 }
 public function testLoggingForInvalidResponse()
 {
     $relativeRequestUri = '/foo/bar';
     $responseHeaders = array('Content-Type' => 'text/html');
     $responseBody = 'an error occurred';
     $connectionResponse = $this->getMockConnectionResponse(400, $responseHeaders, $responseBody);
     $connection = new CommunicatorLoggingTestingConnection($connectionResponse);
     /** @var Connection $connection */
     $communicator = new Communicator($connection, $this->getMockCommunicatorConfiguration());
     $uuidGenerator = $this->getCommunicatorUuidGenerator($connection);
     $httpObfuscator = new HttpObfuscator();
     $rawObfuscatedResponse = $httpObfuscator->getRawObfuscatedResponse($connectionResponse);
     $logger = $this->getMock('\\Ingenico\\Connect\\Sdk\\CommunicatorLogger');
     $logger->expects($this->exactly(2))->method('log')->will($this->returnCallback(function ($message) use($uuidGenerator, $rawObfuscatedResponse) {
         $messageHeader = strstr($message, "\n", true);
         $this->assertNotEmpty($uuidGenerator->getLastGeneratedUuid());
         $this->assertContains($uuidGenerator->getLastGeneratedUuid(), $messageHeader);
         if (strpos($messageHeader, 'Incoming response') === 0) {
             $this->assertEquals(trim(strstr($message, "\n")), $rawObfuscatedResponse);
         }
     }));
     $logger->expects($this->never())->method('logException');
     /** @var CommunicatorLogger $logger */
     $communicator->enableLogging($logger);
     $responseClassMap = $this->getMock('\\Ingenico\\Connect\\Sdk\\ResponseClassMap');
     /** @var ResponseClassMap $responseClassMap */
     try {
         $communicator->get($responseClassMap, $relativeRequestUri);
     } catch (InvalidResponseException $e) {
         $this->assertEquals($connectionResponse, $e->getResponse());
         return;
     }
     $this->fail('an expected exception has not been raised');
 }