10 use PHPUnit_Framework_MockObject_MockObject as MockObject;
22 private $objectManager;
27 private $xmlSecurityMock;
32 private $errorProcessorMock;
37 private $xmlValidator;
47 $this->xmlSecurityMock = $this->getMockBuilder(Security::class)
48 ->disableOriginalConstructor()
51 $this->errorProcessorMock = $this->getMockBuilder(ResponseErrorProcessor::class)
52 ->disableOriginalConstructor()
55 $this->xmlValidator = $this->objectManager->getObject(
58 'xmlSecurity' => $this->xmlSecurityMock,
59 'errorProcessor' => $this->errorProcessorMock,
70 $this->xmlSecurityMock->expects($this->once())->method(
'scan')->with($rawXml)->willReturn(
true);
73 $this->xmlValidator->validate($rawXml);
75 $this->fail($exception->getMessage());
87 $phrase = new \Magento\Framework\Phrase(
'Error #%1 : %2', [
'111',
'Error in parsing request XML']);
89 $this->xmlSecurityMock->expects($this->any())
92 ->willReturn(
$data[
'isGenerateXml']);
93 $this->errorProcessorMock->expects($this->any())
95 ->willReturn($phrase);
98 $this->xmlValidator->validate($rawXml);
100 $this->assertEquals(
$data[
'errorMessage'], $exception->getMessage());
101 if (isset(
$data[
'code'])) {
102 $this->assertEquals(
$data[
'code'], $exception->getCode());
107 $this->fail(
'Exception not thrown for testValidateInvalidXml');
118 'file' =>
'invalidDHLResponseWithMissingXmlTag.xml',
119 'errorMessage' =>
'The response is in the wrong format',
120 'isGenerateXml' =>
false,
125 'file' =>
'invalidDHLResponse.xml',
126 'errorMessage' =>
'The security validation of the XML document has failed.',
127 'isGenerateXml' =>
false,
132 'file' =>
'invalidDHLResponse.xml',
133 'errorMessage' =>
'Error #111 : Error in parsing request XML',
134 'isGenerateXml' =>
true,
invalidXmlResponseProvider()
defined('TESTS_BP')||define('TESTS_BP' __DIR__
testValidateInvalidXml($data)