Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CommunicationTest.php
Go to the documentation of this file.
1 <?php
7 
10 
11 class CommunicationTest extends \PHPUnit\Framework\TestCase
12 {
16  private $converter;
17 
18  public function setUp()
19  {
20  $this->converter = new Communication(new ConverterUtils());
21  }
22 
23  public function testExportsConvert()
24  {
25  $expectedResult = [
26  'name' => 'exports',
27  'xsi:type' => 'array',
28  'item' => [
29  'propertyOne' => [
30  'name' => 'propertyOne',
31  'xsi:type' => 'string',
32  'value' => 'valueOne',
33  ],
34  'propertyTwo' => [
35  'name' => 'propertyTwo',
36  'xsi:type' => 'string',
37  'value' => 'valueTwo',
38  ],
39  ],
40  ];
41  $dom = new \DOMDocument('1.0', 'UTF-8');
42  $dom->load(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'testForm.xml');
43  $domXpath = new \DOMXPath($dom);
44  $classes = $domXpath->query('//form/fieldset/settings/exports')->item(0);
45  $this->assertEquals($expectedResult, $this->converter->convert($classes));
46  }
47 
48  public function testImportsConvert()
49  {
50  $expectedResult = [
51  'name' => 'imports',
52  'xsi:type' => 'array',
53  'item' => [
54  'propertyOne' => [
55  'name' => 'propertyOne',
56  'xsi:type' => 'string',
57  'value' => 'valueOne',
58  ],
59  'propertyTwo' => [
60  'name' => 'propertyTwo',
61  'xsi:type' => 'string',
62  'value' => 'valueTwo',
63  ],
64  ],
65  ];
66  $dom = new \DOMDocument('1.0', 'UTF-8');
67  $dom->load(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'testForm.xml');
68  $domXpath = new \DOMXPath($dom);
69  $classes = $domXpath->query('//form/fieldset/settings/imports')->item(0);
70  $this->assertEquals($expectedResult, $this->converter->convert($classes));
71  }
72 
73  public function testListensConvert()
74  {
75  $expectedResult = [
76  'name' => 'listens',
77  'xsi:type' => 'array',
78  'item' => [
79  'propertyOne' => [
80  'name' => 'propertyOne',
81  'xsi:type' => 'string',
82  'value' => 'valueOne',
83  ],
84  'propertyTwo' => [
85  'name' => 'propertyTwo',
86  'xsi:type' => 'string',
87  'value' => 'valueTwo',
88  ],
89  ],
90  ];
91  $dom = new \DOMDocument('1.0', 'UTF-8');
92  $dom->load(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'testForm.xml');
93  $domXpath = new \DOMXPath($dom);
94  $classes = $domXpath->query('//form/fieldset/settings/listens')->item(0);
95  $this->assertEquals($expectedResult, $this->converter->convert($classes));
96  }
97 
98  public function testLinksConvert()
99  {
100  $expectedResult = [
101  'name' => 'links',
102  'xsi:type' => 'array',
103  'item' => [
104  'propertyOne' => [
105  'name' => 'propertyOne',
106  'xsi:type' => 'string',
107  'value' => 'valueOne',
108  ],
109  'propertyTwo' => [
110  'name' => 'propertyTwo',
111  'xsi:type' => 'string',
112  'value' => 'valueTwo',
113  ],
114  ],
115  ];
116  $dom = new \DOMDocument('1.0', 'UTF-8');
117  $dom->load(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'testForm.xml');
118  $domXpath = new \DOMXPath($dom);
119  $classes = $domXpath->query('//form/fieldset/settings/links')->item(0);
120  $this->assertEquals($expectedResult, $this->converter->convert($classes));
121  }
122 }
defined('MTF_BOOT_FILE')||define('MTF_BOOT_FILE' __FILE__
Definition: bootstrap.php:7