public function testApiRequestPut() { try { $relativeUri = sprintf('/%s/%s/tokens/1', Client::API_VERSION, self::MERCHANT_ID); $this->defaultCommunicator->put($this->defaultResponseClassMap, $relativeUri); } catch (InvalidResponseException $e) { return; } $this->fail(); }
public function testLoggingForClientErrorResponse() { $relativeRequestUri = '/foo/bar'; $responseHeaders = array('Content-Type' => 'application/json'); $errorResponse = $this->getErrorResponseDataObject(); $connectionResponse = $this->getMockConnectionResponse(400, $responseHeaders, $errorResponse->toJson()); $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->put($responseClassMap, $relativeRequestUri); } catch (ResponseException $e) { return; } $this->fail('an expected exception has not been raised'); }