@@ -125,41 +125,23 @@ private function getResolvedActionsWithArgs($arguments, $actionReferenceKey)
125
125
{
126
126
$ resolvedActions = [];
127
127
128
- // $regexPattern match on: $matches[0] {{section.element(arg.field)}}
129
- // $matches[1] = section.element
130
- // $matches[2] = arg.field
131
- $ regexPattern = '/{{([\w.\[\]]+)\(*([\w.$ \',\s\[\]]+)*\)*}}/ ' ;
132
-
133
128
foreach ($ this ->parsedActions as $ action ) {
134
129
$ varAttributes = array_intersect ($ this ->varAttributes , array_keys ($ action ->getCustomActionAttributes ()));
135
130
$ newActionAttributes = [];
136
131
137
132
if (!empty ($ varAttributes )) {
138
- // 1 check to see if we have pertinent var
139
- foreach ($ varAttributes as $ varAttribute ) {
140
- $ attributeValue = $ action ->getCustomActionAttributes ()[$ varAttribute ];
141
- preg_match_all ($ regexPattern , $ attributeValue , $ matches );
142
- if (empty ($ matches [0 ])) {
143
- continue ;
144
- }
145
-
146
- //get rid of full match {{arg.field(arg.field)}}
147
- array_shift ($ matches );
148
-
149
- $ newActionAttributes [$ varAttribute ] = $ this ->replaceAttributeArguments (
150
- $ arguments ,
151
- $ attributeValue ,
152
- $ matches
153
- );
154
- }
133
+ $ newActionAttributes = $ this ->resolveAttributesWithArguments (
134
+ $ arguments ,
135
+ $ action ->getCustomActionAttributes ()
136
+ );
155
137
}
156
138
157
139
// we append the action reference key to any linked action and the action's merge key as the user might
158
140
// use this action group multiple times in the same test.
159
141
$ resolvedActions [$ action ->getStepKey () . ucfirst ($ actionReferenceKey )] = new ActionObject (
160
142
$ action ->getStepKey () . ucfirst ($ actionReferenceKey ),
161
143
$ action ->getType (),
162
- array_merge ($ action ->getCustomActionAttributes (), $ newActionAttributes ),
144
+ array_replace_recursive ($ action ->getCustomActionAttributes (), $ newActionAttributes ),
163
145
$ action ->getLinkedAction () == null ? null : $ action ->getLinkedAction () . ucfirst ($ actionReferenceKey ),
164
146
$ action ->getOrderOffset (),
165
147
[self ::ACTION_GROUP_ORIGIN_NAME => $ this ->name ,
@@ -170,6 +152,50 @@ private function getResolvedActionsWithArgs($arguments, $actionReferenceKey)
170
152
return $ resolvedActions ;
171
153
}
172
154
155
+ /**
156
+ * Resolves all references to arguments in attributes, and subAttributes.
157
+ * @param array $arguments
158
+ * @param array $attributes
159
+ * @return array
160
+ */
161
+ private function resolveAttributesWithArguments ($ arguments , $ attributes )
162
+ {
163
+ // $regexPattern match on: $matches[0] {{section.element(arg.field)}}
164
+ // $matches[1] = section.element
165
+ // $matches[2] = arg.field
166
+ $ regexPattern = '/{{([\w.\[\]]+)\(*([\w.$ \',\s\[\]]+)*\)*}}/ ' ;
167
+
168
+ $ newActionAttributes = [];
169
+ foreach ($ attributes as $ attributeKey => $ attributeValue ) {
170
+
171
+ if (is_array ($ attributeValue )) {
172
+ // attributes with child elements are parsed as an array, need make recursive call to resolve children
173
+ $ newActionAttributes [$ attributeKey ] = $ this ->resolveAttributesWithArguments (
174
+ $ arguments ,
175
+ $ attributeValue
176
+ );
177
+ continue ;
178
+ }
179
+
180
+ preg_match_all ($ regexPattern , $ attributeValue , $ matches );
181
+
182
+ if (empty ($ matches [0 ])) {
183
+ continue ;
184
+ }
185
+
186
+ //get rid of full match {{arg.field(arg.field)}}
187
+ array_shift ($ matches );
188
+
189
+ $ newActionAttributes [$ attributeKey ] = $ this ->replaceAttributeArguments (
190
+ $ arguments ,
191
+ $ attributeValue ,
192
+ $ matches
193
+ );
194
+ }
195
+ return $ newActionAttributes ;
196
+
197
+ }
198
+
173
199
/**
174
200
* Function that takes an array of replacement arguments, and matches them with args in an actionGroup's attribute.
175
201
* Determines if the replacement arguments are persisted data, and replaces them accordingly.
0 commit comments