6
6
7
7
namespace Magento \FunctionalTestingFramework \Test \Config ;
8
8
9
+ use Magento \FunctionalTestingFramework \Exceptions \Collector \ExceptionCollector ;
9
10
use Magento \FunctionalTestingFramework \Exceptions \XmlException ;
10
11
use Magento \FunctionalTestingFramework \Config \Dom \NodeMergingConfig ;
11
12
use Magento \FunctionalTestingFramework \Config \Dom \NodePathMatcher ;
@@ -21,6 +22,7 @@ class Dom extends \Magento\FunctionalTestingFramework\Config\Dom
21
22
* TestDom constructor.
22
23
* @param string $xml
23
24
* @param string $filename
25
+ * @param ExceptionCollector $exceptionCollector
24
26
* @param array $idAttributes
25
27
* @param string $typeAttributeName
26
28
* @param string $schemaFile
@@ -29,6 +31,7 @@ class Dom extends \Magento\FunctionalTestingFramework\Config\Dom
29
31
public function __construct (
30
32
$ xml ,
31
33
$ filename ,
34
+ $ exceptionCollector ,
32
35
array $ idAttributes = [],
33
36
$ typeAttributeName = null ,
34
37
$ schemaFile = null ,
@@ -38,7 +41,7 @@ public function __construct(
38
41
$ this ->nodeMergingConfig = new NodeMergingConfig (new NodePathMatcher (), $ idAttributes );
39
42
$ this ->typeAttributeName = $ typeAttributeName ;
40
43
$ this ->errorFormat = $ errorFormat ;
41
- $ this ->dom = $ this ->initDom ($ xml , $ filename );
44
+ $ this ->dom = $ this ->initDom ($ xml , $ filename, $ exceptionCollector );
42
45
$ this ->rootNamespace = $ this ->dom ->lookupNamespaceUri ($ this ->dom ->namespaceURI );
43
46
}
44
47
@@ -47,9 +50,10 @@ public function __construct(
47
50
*
48
51
* @param string $xml
49
52
* @param string|null $filename
53
+ * @param ExceptionCollector $exceptionCollector
50
54
* @return \DOMDocument
51
55
*/
52
- public function initDom ($ xml , $ filename = null )
56
+ public function initDom ($ xml , $ filename = null , $ exceptionCollector = null )
53
57
{
54
58
$ dom = parent ::initDom ($ xml );
55
59
@@ -58,7 +62,7 @@ public function initDom($xml, $filename = null)
58
62
foreach ($ testNodes as $ testNode ) {
59
63
/** @var \DOMElement $testNode */
60
64
$ testNode ->setAttribute (self ::TEST_META_FILENAME_ATTRIBUTE , $ filename );
61
- $ this ->validateTestDomStepKeys ($ testNode , $ filename );
65
+ $ this ->validateDomStepKeys ($ testNode , $ filename, ' Test ' , $ exceptionCollector );
62
66
}
63
67
}
64
68
@@ -70,11 +74,12 @@ public function initDom($xml, $filename = null)
70
74
*
71
75
* @param string $xml
72
76
* @param string|null $filename
77
+ * @param ExceptionCollector $exceptionCollector
73
78
* @return void
74
79
*/
75
- public function merge ($ xml , $ filename = null )
80
+ public function merge ($ xml , $ filename = null , $ exceptionCollector = null )
76
81
{
77
- $ dom = $ this ->initDom ($ xml , $ filename );
82
+ $ dom = $ this ->initDom ($ xml , $ filename, $ exceptionCollector );
78
83
$ this ->mergeNode ($ dom ->documentElement , '' );
79
84
}
80
85
@@ -83,10 +88,12 @@ public function merge($xml, $filename = null)
83
88
*
84
89
* @param \DOMElement $testNode
85
90
* @param string $filename
91
+ * @param string $type
92
+ * @param ExceptionCollector $exceptionCollector
86
93
* @return void
87
94
* @throws XmlException
88
95
*/
89
- private function validateTestDomStepKeys ($ testNode , $ filename )
96
+ protected function validateDomStepKeys ($ testNode , $ filename, $ type , $ exceptionCollector )
90
97
{
91
98
$ childNodes = $ testNode ->childNodes ;
92
99
@@ -99,7 +106,7 @@ private function validateTestDomStepKeys($testNode, $filename)
99
106
}
100
107
101
108
if (in_array ($ currentNode ->nodeName , self ::TEST_HOOK_NAMES )) {
102
- $ this ->validateTestDomStepKeys ($ currentNode , $ filename );
109
+ $ this ->validateDomStepKeys ($ currentNode , $ filename, $ type , $ exceptionCollector );
103
110
}
104
111
105
112
if ($ currentNode ->hasAttribute ('stepKey ' )) {
@@ -116,7 +123,8 @@ private function validateTestDomStepKeys($testNode, $filename)
116
123
$ stepKeyError .= "\tstepKey: {$ duplicateValue } is used more than once. \n" ;
117
124
}
118
125
119
- throw new XmlException ("Tests cannot use stepKey more than once! \t\n{$ stepKeyError }\tin file: {$ filename }" );
126
+ $ errorMsg = "{$ type }s cannot use stepKey more than once. \t\n{$ stepKeyError }\tin file: {$ filename }" ;
127
+ $ exceptionCollector ->addError ($ filename , $ errorMsg );
120
128
}
121
129
}
122
130
}
0 commit comments