19
19
*/
20
20
class Dom extends \Magento \FunctionalTestingFramework \Config \MftfDom
21
21
{
22
- const TEST_FILE_NAME_ENDING = 'Test ' ;
22
+ const TEST_FILE_NAME_ENDING = 'Test.xml ' ;
23
23
const TEST_META_FILENAME_ATTRIBUTE = 'filename ' ;
24
24
const TEST_META_NAME_ATTRIBUTE = 'name ' ;
25
25
const TEST_HOOK_NAMES = ["after " , "before " ];
26
26
const TEST_MERGE_POINTER_BEFORE = "insertBefore " ;
27
27
const TEST_MERGE_POINTER_AFTER = "insertAfter " ;
28
28
29
29
/**
30
- * NodeValidationUtil
30
+ * NodeValidationUtil for test actions
31
31
* @var DuplicateNodeValidationUtil
32
32
*/
33
- protected $ validationUtil ;
33
+ protected $ actionsValidationUtil ;
34
+
35
+ /**
36
+ * NodeValidationUtil for test names
37
+ * @var DuplicateNodeValidationUtil
38
+ */
39
+ protected $ testsValidationUtil ;
34
40
35
41
/**
36
42
* ExceptionCollector
@@ -57,7 +63,8 @@ public function __construct(
57
63
$ schemaFile = null ,
58
64
$ errorFormat = self ::ERROR_FORMAT_DEFAULT
59
65
) {
60
- $ this ->validationUtil = new DuplicateNodeValidationUtil ('stepKey ' , $ exceptionCollector );
66
+ $ this ->actionsValidationUtil = new DuplicateNodeValidationUtil ('stepKey ' , $ exceptionCollector );
67
+ $ this ->testsValidationUtil = new DuplicateNodeValidationUtil ('name ' , $ exceptionCollector );
61
68
$ this ->exceptionCollector = $ exceptionCollector ;
62
69
parent ::__construct (
63
70
$ xml ,
@@ -81,8 +88,14 @@ public function initDom($xml, $filename = null)
81
88
{
82
89
$ dom = parent ::initDom ($ xml , $ filename );
83
90
84
- if (strpos ($ filename , self ::TEST_FILE_NAME_ENDING )) {
91
+ if ($ this ->checkFilenameSuffix ($ filename , self ::TEST_FILE_NAME_ENDING )) {
92
+ $ testsNode = $ dom ->getElementsByTagName ('tests ' )[0 ];
85
93
$ testNodes = $ dom ->getElementsByTagName ('test ' );
94
+ $ this ->testsValidationUtil ->validateChildUniqueness (
95
+ $ testsNode ,
96
+ $ filename ,
97
+ null
98
+ );
86
99
foreach ($ testNodes as $ testNode ) {
87
100
/** @var \DOMElement $testNode */
88
101
$ testNode ->setAttribute (self ::TEST_META_FILENAME_ATTRIBUTE , $ filename );
@@ -102,7 +115,7 @@ public function initDom($xml, $filename = null)
102
115
);
103
116
}
104
117
105
- $ this ->validationUtil ->validateChildUniqueness (
118
+ $ this ->actionsValidationUtil ->validateChildUniqueness (
106
119
$ testNode ,
107
120
$ filename ,
108
121
$ testNode ->getAttribute (self ::TEST_META_NAME_ATTRIBUTE )
@@ -111,14 +124,14 @@ public function initDom($xml, $filename = null)
111
124
$ afterNode = $ testNode ->getElementsByTagName ('after ' )->item (0 );
112
125
113
126
if (isset ($ beforeNode )) {
114
- $ this ->validationUtil ->validateChildUniqueness (
127
+ $ this ->actionsValidationUtil ->validateChildUniqueness (
115
128
$ beforeNode ,
116
129
$ filename ,
117
130
$ testNode ->getAttribute (self ::TEST_META_NAME_ATTRIBUTE ) . "/before "
118
131
);
119
132
}
120
133
if (isset ($ afterNode )) {
121
- $ this ->validationUtil ->validateChildUniqueness (
134
+ $ this ->actionsValidationUtil ->validateChildUniqueness (
122
135
$ afterNode ,
123
136
$ filename ,
124
137
$ testNode ->getAttribute (self ::TEST_META_NAME_ATTRIBUTE ) . "/after "
0 commit comments