55 */
66namespace Magento \FunctionalTestingFramework \Util \Script ;
77
8+ use Magento \FunctionalTestingFramework \Test \Handlers \TestObjectHandler ;
9+ use Magento \FunctionalTestingFramework \Filter \FilterList ;
10+ use Magento \FunctionalTestingFramework \Config \MftfApplicationConfig ;
11+
812/**
913 * TestDependencyUtil class that contains helper functions for static and upgrade scripts
1014 *
@@ -144,11 +148,16 @@ public function getModuleName(string $filePath, array $moduleNameToPath): ?strin
144148 /**
145149 * Return array of merge test modules and file path with same test name.
146150 * @param array $testDependencies
151+ * @param array $filterList
147152 * @param array $extendedTestMapping
148153 * @return array
149154 */
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 ():[];
152161 $ temp_array = array_reverse (array_column ($ testDependencies , "test_name " ), true );
153162 if (!empty ($ extendedTestMapping )) {
154163 foreach ($ extendedTestMapping as $ value ) {
@@ -165,20 +174,42 @@ public function mergeDependenciesForExtendingTests(array $testDependencies, arra
165174 }
166175 $ testDependencies = [];
167176 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+ )
177191 )
178- )
179- ),
180- ];
192+ ),
193+ ];
194+ }
181195 }
182196 return $ testDependencies ;
183197 }
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+ }
184215}
0 commit comments