Skip to content

Commit 1639361

Browse files
committed
MQE-1650: Update MFTF configuration to read Test entities from new location
- improvement in ComposerJsonFinder
1 parent 94b67a7 commit 1639361

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/Magento/FunctionalTestingFramework/Composer/Util/ComposerJsonFinder.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace 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
}

src/Magento/FunctionalTestingFramework/Util/ComposerModuleResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)