forked from magento/magento2-functional-testing-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathActionGroupDomTest.php
71 lines (63 loc) · 2.48 KB
/
ActionGroupDomTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace tests\unit\Magento\FunctionalTestFramework\Test\Config;
use Magento\FunctionalTestingFramework\Exceptions\Collector\ExceptionCollector;
use Magento\FunctionalTestingFramework\Config\Dom\ValidationException;
use Magento\FunctionalTestingFramework\Test\Config\ActionGroupDom;
use tests\unit\Util\MagentoTestCase;
class ActionGroupDomTest extends MagentoTestCase
{
/**
* Test Action Group duplicate step key validation
*/
public function testActionGroupDomStepKeyValidation()
{
$sampleXml = "<actionGroups>
<actionGroup name=\"actionGroupWithoutArguments\">
<wait time=\"1\" stepKey=\"waitForNothing\" />
<wait time=\"2\" stepKey=\"waitForNothing\" />
</actionGroup>
</actionGroups>";
$exceptionCollector = new ExceptionCollector();
new ActionGroupDom($sampleXml, 'dupeStepKeyActionGroup.xml', $exceptionCollector);
$this->expectException(\Exception::class);
$exceptionCollector->throwException();
}
/**
* Test Action Group invalid XML
*/
public function testActionGroupDomInvalidXmlValidation()
{
$sampleXml = "<actionGroups>
<actionGroup name=\"sampleActionGroup\">
<wait>
</actionGroup>
</actionGroups>";
$exceptionCollector = new ExceptionCollector();
$this->expectException(ValidationException::class);
$this->expectExceptionMessage("XML Parse Error: invalid.xml\n");
new ActionGroupDom($sampleXml, 'invalid.xml', $exceptionCollector);
}
/**
* Test detection of two ActionGroups with the same Name in the same file.
*/
public function testActionGroupDomDuplicateActionGroupsValidation()
{
$sampleXml = '<actionGroups>
<actionGroup name="actionGroupName">
<wait time="1" stepKey="key1" />
</actionGroup>
<actionGroup name="actionGroupName">
<wait time="1" stepKey="key1" />
</actionGroup>
</actionGroups>';
$exceptionCollector = new ExceptionCollector();
new ActionGroupDom($sampleXml, 'dupeNameActionGroup.xml', $exceptionCollector);
$this->expectException(\Exception::class);
$this->expectExceptionMessageMatches("/name: actionGroupName is used more than once./");
$exceptionCollector->throwException();
}
}