Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DuplicateNodeValidationUtilTest.php
Go to the documentation of this file.
1 <?php
8 
14 
16 {
20  public function testTestActionValidation()
21  {
22  // Test Data
23  $xml = '<tests>
24  <test name="test">
25  <comment userInput="input1" stepKey="key1"/>
26  <comment userInput="input2" stepKey="key1"/>
27  </test>
28  </tests>
29  ';
30  $uniqueIdentifier = "stepKey";
31  $filename = "file";
32  $testName = "test";
33 
34  // Perform Test
35  $dom = new \DOMDocument();
36  $dom->loadXML($xml);
37  $testNode = $dom->getElementsByTagName('test')->item(0);
38 
39  $exceptionCollector = new ExceptionCollector();
40  $validator = new DuplicateNodeValidationUtil($uniqueIdentifier, $exceptionCollector);
41  $validator->validateChildUniqueness(
42  $testNode,
43  $filename,
44  $testName
45  );
46  $this->expectException(\Exception::class);
47  $exceptionCollector->throwException();
48  }
49 }