5
5
*/
6
6
namespace Magento \FunctionalTestingFramework \Util \Script ;
7
7
8
+ use Magento \FunctionalTestingFramework \Test \Handlers \TestObjectHandler ;
9
+ use Magento \FunctionalTestingFramework \Filter \FilterList ;
10
+
11
+
8
12
/**
9
13
* TestDependencyUtil class that contains helper functions for static and upgrade scripts
10
14
*
@@ -153,6 +157,7 @@ public function mergeDependenciesForExtendingTests(
153
157
array $ filterList ,
154
158
array $ extendedTestMapping = []
155
159
): array {
160
+ $ filteredTestNames = (count ($ filterList )>0 )?$ this ->getFilteredValues ($ filterList ):[];
156
161
$ temp_array = array_reverse (array_column ($ testDependencies , "test_name " ), true );
157
162
if (!empty ($ extendedTestMapping )) {
158
163
foreach ($ extendedTestMapping as $ value ) {
@@ -169,18 +174,7 @@ public function mergeDependenciesForExtendingTests(
169
174
}
170
175
$ testDependencies = [];
171
176
foreach ($ temp_array as $ testDependencyArray ) {
172
- $ domDocument = new \DOMDocument ();
173
- $ domDocument ->load ($ testDependencyArray [0 ]["file_path " ]);
174
- $ filterResult = $ this ->getAttributesFromDOMNodeList (
175
- $ domDocument ->getElementsByTagName ("group " ),
176
- ["type " => "value " ]
177
- );
178
- $ excludeGroup = $ filterList ['excludeGroup ' ]??[];
179
- if (count (array_intersect (
180
- call_user_func_array ('array_merge ' , $ filterResult ),
181
- $ excludeGroup
182
- ))==0
183
- ) {
177
+ if ((empty ($ filteredTestNames )) || (in_array ($ testDependencyArray [0 ]["test_name " ],$ filteredTestNames ))) {
184
178
$ testDependencies [] = [
185
179
"file_path " => array_column ($ testDependencyArray , 'file_path ' ),
186
180
"full_name " => $ testDependencyArray [0 ]["full_name " ],
@@ -200,26 +194,18 @@ public function mergeDependenciesForExtendingTests(
200
194
}
201
195
202
196
/**
203
- * Return attribute value for each node in DOMNodeList as an array
204
- *
205
- * @param DOMNodeList $nodes
206
- * @param string $attributeName
207
197
* @return array
208
198
*/
209
- private function getAttributesFromDOMNodeList ($ nodes , $ attributeName )
210
- {
211
- $ attributes = [];
212
- foreach ($ nodes as $ node ) {
213
- if (is_string ($ attributeName )) {
214
- $ attributeValues = $ node ->getAttribute ($ attributeName );
215
- } else {
216
- $ attributeValues = [$ node ->getAttribute (key ($ attributeName )) =>
217
- $ node ->getAttribute ($ attributeName [key ($ attributeName )])];
218
- }
219
- if (!empty ($ attributeValues )) {
220
- $ attributes [] = array_values ($ attributeValues );
221
- }
199
+ public function getFilteredValues (array $ filterList ) {
200
+
201
+ $ testObjects = TestObjectHandler::getInstance ()->getAllObjects ();
202
+ $ fileList = new FilterList ($ filterList );
203
+ foreach ( $ fileList ->getFilters () as $ filterData ) {
204
+ $ filterData ->filter ($ testObjects );
205
+ }
206
+ foreach ($ testObjects as $ testObjects ) {
207
+ $ testNames [] = $ testObjects ->getName ();
222
208
}
223
- return array_values ( $ attributes ) ;
209
+ return $ testNames ;
224
210
}
225
211
}
0 commit comments