-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathActionGroupDom.php
76 lines (69 loc) · 2.88 KB
/
ActionGroupDom.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
72
73
74
75
76
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\FunctionalTestingFramework\Test\Config;
use Magento\FunctionalTestingFramework\Exceptions\Collector\ExceptionCollector;
use Magento\FunctionalTestingFramework\Util\Validation\DuplicateNodeValidationUtil;
/**
* MFTF actionGroup.xml configuration XML DOM utility
* @package Magento\FunctionalTestingFramework\Test\Config
*/
class ActionGroupDom extends Dom
{
const ACTION_GROUP_FILE_NAME_ENDING = "ActionGroup.xml";
const ACTION_GROUP_META_NAME_ATTRIBUTE = "name";
/**
* Takes a dom element from xml and appends the filename based on location while also validating the action group
* step key.
*
* @param string $xml
* @param string|null $filename
* @return \DOMDocument
*/
public function initDom($xml, $filename = null)
{
$dom = parent::initDom($xml, $filename);
if ($this->checkFilenameSuffix($filename, self::ACTION_GROUP_FILE_NAME_ENDING)) {
$actionGroupsNode = $dom->getElementsByTagName('actionGroups')[0];
$this->testsValidationUtil->validateChildUniqueness(
$actionGroupsNode,
$filename,
null
);
// Validate single action group node per file
$this->singleNodePerFileValidationUtil->validateSingleNodeForTag(
$dom,
'actionGroup',
$filename
);
if ($dom->getElementsByTagName('actionGroup')->length > 0) {
/** @var \DOMElement $actionGroupNode */
$actionGroupNode = $dom->getElementsByTagName('actionGroup')[0];
$actionGroupNode->setAttribute(self::TEST_META_FILENAME_ATTRIBUTE, $filename);
$this->actionsValidationUtil->validateChildUniqueness(
$actionGroupNode,
$filename,
$actionGroupNode->getAttribute(self::ACTION_GROUP_META_NAME_ATTRIBUTE)
);
if ($actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_AFTER) !== "") {
$this->appendMergePointerToActions(
$actionGroupNode,
self::TEST_MERGE_POINTER_AFTER,
$actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_AFTER),
$filename
);
} elseif ($actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_BEFORE) !== "") {
$this->appendMergePointerToActions(
$actionGroupNode,
self::TEST_MERGE_POINTER_BEFORE,
$actionGroupNode->getAttribute(self::TEST_MERGE_POINTER_BEFORE),
$filename
);
}
}
}
return $dom;
}
}