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
+ use Magento \FunctionalTestingFramework \Config \MftfApplicationConfig ;
11
+
8
12
/**
9
13
* TestDependencyUtil class that contains helper functions for static and upgrade scripts
10
14
*
@@ -144,11 +148,16 @@ public function getModuleName(string $filePath, array $moduleNameToPath): ?strin
144
148
/**
145
149
* Return array of merge test modules and file path with same test name.
146
150
* @param array $testDependencies
151
+ * @param array $filterList
147
152
* @param array $extendedTestMapping
148
153
* @return array
149
154
*/
150
- public function mergeDependenciesForExtendingTests (array $ testDependencies , array $ extendedTestMapping = []): array
151
- {
155
+ public function mergeDependenciesForExtendingTests (
156
+ array $ testDependencies ,
157
+ array $ filterList ,
158
+ array $ extendedTestMapping = []
159
+ ): array {
160
+ $ filteredTestNames = (count ($ filterList )>0 )?$ this ->getFilteredTestNames ():[];
152
161
$ temp_array = array_reverse (array_column ($ testDependencies , "test_name " ), true );
153
162
if (!empty ($ extendedTestMapping )) {
154
163
foreach ($ extendedTestMapping as $ value ) {
@@ -165,20 +174,42 @@ public function mergeDependenciesForExtendingTests(array $testDependencies, arra
165
174
}
166
175
$ testDependencies = [];
167
176
foreach ($ temp_array as $ testDependencyArray ) {
168
- $ testDependencies [] = [
169
- "file_path " => array_column ($ testDependencyArray , 'file_path ' ),
170
- "full_name " => $ testDependencyArray [0 ]["full_name " ],
171
- "test_name " => $ testDependencyArray [0 ]["test_name " ],
172
- "test_modules " =>array_values (
173
- array_unique (
174
- call_user_func_array (
175
- 'array_merge ' ,
176
- array_column ($ testDependencyArray , 'test_modules ' )
177
+ if ((
178
+ empty ($ filterList )) ||
179
+ isset ($ filteredTestNames [$ testDependencyArray [0 ]["test_name " ]])
180
+ ) {
181
+ $ testDependencies [] = [
182
+ "file_path " => array_column ($ testDependencyArray , 'file_path ' ),
183
+ "full_name " => $ testDependencyArray [0 ]["full_name " ],
184
+ "test_name " => $ testDependencyArray [0 ]["test_name " ],
185
+ "test_modules " => array_values (
186
+ array_unique (
187
+ call_user_func_array (
188
+ 'array_merge ' ,
189
+ array_column ($ testDependencyArray , 'test_modules ' )
190
+ )
177
191
)
178
- )
179
- ),
180
- ];
192
+ ),
193
+ ];
194
+ }
181
195
}
182
196
return $ testDependencies ;
183
197
}
198
+
199
+ /**
200
+ * Return array of merge test modules and file path with same test name.
201
+ * @return array
202
+ */
203
+ public function getFilteredTestNames ()
204
+ {
205
+ $ testObjects = TestObjectHandler::getInstance ()->getAllObjects ();
206
+ $ filters = MftfApplicationConfig::getConfig ()->getFilterList ()->getFilters ();
207
+ foreach ($ filters as $ filter ) {
208
+ $ filter ->filter ($ testObjects );
209
+ }
210
+ $ testValues = array_map (function ($ testObjects ) {
211
+ return $ testObjects ->getName ();
212
+ }, $ testObjects );
213
+ return $ testValues ;
214
+ }
184
215
}
0 commit comments