File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
src/Magento/FunctionalTestingFramework Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 55 */
66namespace Magento \FunctionalTestingFramework \Composer \Util ;
77
8+ use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
9+
810/**
911 * Class ComposerJsonFinder searches composer json file for possible test module code paths
1012 */
@@ -33,4 +35,34 @@ public function findAllComposerJsonFiles($directory)
3335 return $ jsonFileList ;
3436 }
3537 }
38+
39+ /**
40+ * Find absolute paths of all composer json files in a given directory at certain depths
41+ *
42+ * @param string $directory
43+ * @param integer $depth
44+ * @return array
45+ */
46+ public function finComposerJsonFilesAtDepth ($ directory , $ depth )
47+ {
48+ $ directory = realpath ($ directory );
49+ $ jsonPattern = DIRECTORY_SEPARATOR . "composer.json " ;
50+ $ subDirectoryPattern = DIRECTORY_SEPARATOR . "* " ;
51+
52+ $ jsonFileList = [];
53+ if ($ depth > 0 ) {
54+ foreach (glob ($ directory . $ subDirectoryPattern , GLOB_ONLYDIR ) as $ dir ) {
55+ $ jsonFileList = array_merge_recursive (
56+ $ jsonFileList ,
57+ self ::finComposerJsonFilesAtDepth ($ dir , $ depth -1 )
58+ );
59+ }
60+ } elseif ($ depth == 0 ) {
61+ $ jsonFileList = glob ($ directory . $ jsonPattern );
62+ if ($ jsonFileList === false ) {
63+ $ jsonFileList = [];
64+ }
65+ }
66+ return $ jsonFileList ;
67+ }
3668}
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ private function getTestModules($directory)
107107 // Find all composer json files under directory
108108 $ modules = [];
109109 $ jsonFinder = new ComposerJsonFinder ();
110- $ fileList = $ jsonFinder ->findAllComposerJsonFiles ($ normalizedDir );
110+ $ fileList = $ jsonFinder ->finComposerJsonFilesAtDepth ($ normalizedDir, 2 );
111111 foreach ($ fileList as $ file ) {
112112 // Parse composer json for test module name and path information
113113 $ composerInfo = new ComposerPackager (
You can’t perform that action at this time.
0 commit comments