6
6
7
7
namespace Magento \FunctionalTestingFramework \Test \Util ;
8
8
9
+ use Magento \FunctionalTestingFramework \Config \MftfApplicationConfig ;
9
10
use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
10
11
use Magento \FunctionalTestingFramework \Exceptions \TestReferenceException ;
11
12
use Magento \FunctionalTestingFramework \Exceptions \XmlException ;
@@ -65,8 +66,6 @@ public function extractActions($testActions, $testName = null)
65
66
self ::TEST_STEP_MERGE_KEY ,
66
67
self ::NODE_NAME
67
68
);
68
- $ linkedAction = null ;
69
- $ order = null ;
70
69
71
70
// Flatten AssertSorted "array" element to parameterArray
72
71
if (isset ($ actionData ["array " ])) {
@@ -77,24 +76,12 @@ public function extractActions($testActions, $testName = null)
77
76
$ actionAttributes = $ this ->processActionGroupArgs ($ actionAttributes );
78
77
}
79
78
80
- if (array_key_exists (self ::TEST_ACTION_BEFORE , $ actionData )
81
- and array_key_exists (self ::TEST_ACTION_AFTER , $ actionData )) {
82
- throw new XmlException (sprintf (self ::BEFORE_AFTER_ERROR_MSG , $ actionName ));
83
- }
84
-
85
- if (array_key_exists (self ::TEST_ACTION_BEFORE , $ actionData )) {
86
- $ linkedAction = $ actionData [self ::TEST_ACTION_BEFORE ];
87
- $ order = self ::TEST_ACTION_BEFORE ;
88
- } elseif (array_key_exists (self ::TEST_ACTION_AFTER , $ actionData )) {
89
- $ linkedAction = $ actionData [self ::TEST_ACTION_AFTER ];
90
- $ order = self ::TEST_ACTION_AFTER ;
91
- }
92
-
79
+ $ linkedAction = $ this ->processLinkedActions ($ actionName , $ actionData );
93
80
$ actions = $ this ->extractFieldActions ($ actionData , $ actions );
94
81
$ actionAttributes = $ this ->extractFieldReferences ($ actionData , $ actionAttributes );
95
82
96
- if ($ linkedAction != null ) {
97
- $ stepKeyRefs [$ linkedAction ][] = $ stepKey ;
83
+ if ($ linkedAction[ ' stepKey ' ] != null ) {
84
+ $ stepKeyRefs [$ linkedAction[ ' stepKey ' ] ][] = $ stepKey ;
98
85
}
99
86
100
87
// TODO this is to be implemented later. Currently the schema does not use or need return var.
@@ -106,8 +93,8 @@ public function extractActions($testActions, $testName = null)
106
93
$ stepKey ,
107
94
$ actionData [self ::NODE_NAME ],
108
95
$ actionAttributes ,
109
- $ linkedAction ,
110
- $ order
96
+ $ linkedAction[ ' stepKey ' ] ,
97
+ $ linkedAction [ ' order ' ]
111
98
);
112
99
}
113
100
@@ -116,6 +103,34 @@ public function extractActions($testActions, $testName = null)
116
103
return $ actions ;
117
104
}
118
105
106
+ /**
107
+ * Function which processes any actions which have an explicit reference to an additional step for merging purposes.
108
+ * Returns an array with keys corresponding to the linked action's stepKey and order.
109
+ *
110
+ * @param string $actionName
111
+ * @param array $actionData
112
+ * @return array
113
+ * @throws XmlException
114
+ */
115
+ private function processLinkedActions ($ actionName , $ actionData )
116
+ {
117
+ $ linkedAction =['stepKey ' => null , 'order ' => null ];
118
+ if (array_key_exists (self ::TEST_ACTION_BEFORE , $ actionData )
119
+ and array_key_exists (self ::TEST_ACTION_AFTER , $ actionData )) {
120
+ throw new XmlException (sprintf (self ::BEFORE_AFTER_ERROR_MSG , $ actionName ));
121
+ }
122
+
123
+ if (array_key_exists (self ::TEST_ACTION_BEFORE , $ actionData )) {
124
+ $ linkedAction ['stepKey ' ] = $ actionData [self ::TEST_ACTION_BEFORE ];
125
+ $ linkedAction ['order ' ] = self ::TEST_ACTION_BEFORE ;
126
+ } elseif (array_key_exists (self ::TEST_ACTION_AFTER , $ actionData )) {
127
+ $ linkedAction ['stepKey ' ] = $ actionData [self ::TEST_ACTION_AFTER ];
128
+ $ linkedAction ['order ' ] = self ::TEST_ACTION_AFTER ;
129
+ }
130
+
131
+ return $ linkedAction ;
132
+ }
133
+
119
134
/**
120
135
* Takes the action group reference and parses out arguments as an array that can be passed to override defaults
121
136
* defined in the action group xml.
@@ -238,11 +253,16 @@ private function auditMergeSteps($stepKeyRefs, $testName)
238
253
return count ($ value ) > 1 ;
239
254
});
240
255
256
+ $ multipleActionsError = "" ;
241
257
foreach ($ atRiskStepRef as $ stepKey => $ stepRefs ) {
242
- print "multiple actions referencing step key {$ stepKey } in test {$ testName }: \n" ;
243
- array_walk ($ stepRefs , function ($ value ) {
244
- print "\t{$ value }\n" ;
258
+ $ multipleActionsError .= "multiple actions referencing step key {$ stepKey } in test {$ testName }: \n" ;
259
+ array_walk ($ stepRefs , function ($ value ) use (& $ multipleActionsError ) {
260
+ $ multipleActionsError .= "\t{$ value }\n" ;
245
261
});
246
262
}
263
+
264
+ if (MftfApplicationConfig::getConfig ()->verboseEnabled ()) {
265
+ print $ multipleActionsError ;
266
+ }
247
267
}
248
268
}
0 commit comments