Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ResponseErrorProcessorTest.php
Go to the documentation of this file.
1 <?php
8 
12 
13 class ResponseErrorProcessorTest extends \PHPUnit\Framework\TestCase
14 {
18  private $objectManager;
19 
23  private $responseErrorProcessor;
24 
25  protected function setUp()
26  {
27  $this->objectManager = new ObjectManager($this);
28 
29  $this->responseErrorProcessor = $this->objectManager->getObject(ResponseErrorProcessor::class);
30  }
31 
38  public function testProcess($data)
39  {
40  $xml = $this->getXml($data['file']);
41 
42  $result = $this->responseErrorProcessor->process($xml, $data['isShippingLabel']);
43 
44  $this->assertEquals($data['errorMessage'], $result->render());
45  $this->assertNotNull($result->getArguments()[0]);
46  }
47 
54  private function getXml($file)
55  {
56  $rawXml = file_get_contents(__DIR__ . '/_files/' . $file);
57  return simplexml_load_string($rawXml, Element::class);
58  }
59 
63  public function processProvider()
64  {
65  return [
66  [
67  [
68  'file' => 'invalidDHLResponse.xml',
69  'errorMessage' => 'Error #111 : Error in parsing request XML',
70  'isShippingLabel' => false,
71  ],
72  ],
73  [
74  [
75  'file' => 'invalidDHLResponseForShippingLabel.xml',
76  'errorMessage' => 'Error #123 : Error in shipping request XML',
77  'isShippingLabel' => true,
78  ],
79  ],
80  [
81  [
82  'file' => 'invalidDHLResponseForQuoteResponse.xml',
83  'errorMessage' => 'Error #321 : Error in quote request XML',
84  'isShippingLabel' => false,
85  ],
86  ],
87  ];
88  }
89 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60