public function testApiRequestDelete() { try { $relativeUri = sprintf('/%s/%s/tokens/1', Client::API_VERSION, self::MERCHANT_ID); $this->defaultCommunicator->delete($this->defaultResponseClassMap, $relativeUri); } catch (ReferenceException $e) { return; } $this->fail(); }
public function testLoggingForCommunicationException() { $relativeRequestUri = '/foo/bar'; $errorException = new ErrorException('Test error exception'); $connection = new CommunicatorLoggingTestingConnection(null, $errorException); /** @var Connection $connection */ $communicator = new Communicator($connection, $this->getMockCommunicatorConfiguration()); $uuidGenerator = $this->getCommunicatorUuidGenerator($connection); $logger = $this->getMock('\\Ingenico\\Connect\\Sdk\\CommunicatorLogger'); $logger->expects($this->once())->method('log')->will($this->returnCallback(function ($message) use($uuidGenerator) { $messageHeader = strstr($message, "\n", true); $this->assertNotEmpty($uuidGenerator->getLastGeneratedUuid()); $this->assertContains($uuidGenerator->getLastGeneratedUuid(), $messageHeader); })); $logger->expects($this->once())->method('logException')->will($this->returnCallback(function ($message, $exception) use($uuidGenerator, $errorException) { $this->assertNotContains("\n", $message); $this->assertNotEmpty($uuidGenerator->getLastGeneratedUuid()); $this->assertContains($uuidGenerator->getLastGeneratedUuid(), $message); $this->assertEquals($errorException, $exception); })); /** @var CommunicatorLogger $logger */ $communicator->enableLogging($logger); $responseClassMap = $this->getMock('\\Ingenico\\Connect\\Sdk\\ResponseClassMap'); /** @var ResponseClassMap $responseClassMap */ try { $communicator->delete($responseClassMap, $relativeRequestUri); } catch (ErrorException $e) { return; } $this->fail('an expected exception has not been raised'); }