@@ -188,6 +188,16 @@ class DependencyTest extends \PHPUnit\Framework\TestCase
188188 */
189189 private $ undeclaredDependencyBlacklist ;
190190
191+ /**
192+ * @var array|null
193+ */
194+ private static $ extensionConflicts = null ;
195+
196+ /**
197+ * @var array|null
198+ */
199+ private static $ allowedDependencies = null ;
200+
191201 /**
192202 * Sets up data
193203 *
@@ -1214,26 +1224,8 @@ public function testDirectExtensionDependencies()
12141224 {
12151225 $ invoker = new \Magento \Framework \App \Utility \AggregateInvoker ($ this );
12161226
1217- // @todo - move to config
1218- $ extensionConflictList = [
1219- // the following modules must be disabled when Live Search is used
1220- // so core modules must not be dependent on them
1221- 'Magento\LiveSearch ' => [
1222- 'Magento\Elasticsearch ' ,
1223- 'Magento\Elasticsearch6 ' ,
1224- 'Magento\Elasticsearch7 ' ,
1225- 'Magento\ElasticsearchCatalogPermissions ' ,
1226- ],
1227- ];
1228-
1229- // @todo - move to config
1230- $ allowedDependencies = [
1231- 'Magento\Elasticsearch ' => [
1232- 'Magento\Elasticsearch ' ,
1233- 'Magento\Elasticsearch6 ' ,
1234- 'Magento\Elasticsearch7 '
1235- ]
1236- ];
1227+ $ extensionConflictList = self ::getExtensionConflicts ();
1228+ $ allowedDependencies = self ::getAllowedDependencies ();
12371229
12381230 $ invoker (
12391231 /**
@@ -1290,4 +1282,42 @@ function ($fileType, $file) use ($extensionConflictList, $allowedDependencies) {
12901282 $ this ->getAllFiles ()
12911283 );
12921284 }
1285+
1286+ /**
1287+ * Initialize extension conflicts list.
1288+ *
1289+ * @return array
1290+ */
1291+ private static function getExtensionConflicts (): array
1292+ {
1293+ if (null === self ::$ extensionConflicts ) {
1294+ $ extensionConflictsFilePattern =
1295+ realpath (__DIR__ ) . '/_files/extension_dependencies_test/extension_conflicts/*.php ' ;
1296+ $ extensionConflicts = [];
1297+ foreach (glob ($ extensionConflictsFilePattern ) as $ fileName ) {
1298+ $ extensionConflicts [] = include $ fileName ;
1299+ }
1300+ self ::$ extensionConflicts = array_merge ([], ...$ extensionConflicts );
1301+ }
1302+ return self ::$ extensionConflicts ;
1303+ }
1304+
1305+ /**
1306+ * Initialize allowed dependencies.
1307+ *
1308+ * @return array
1309+ */
1310+ private static function getAllowedDependencies (): array
1311+ {
1312+ if (null === self ::$ allowedDependencies ) {
1313+ $ allowedDependenciesFilePattern =
1314+ realpath (__DIR__ ) . '/_files/extension_dependencies_test/allowed_dependencies/*.php ' ;
1315+ $ allowedDependencies = [];
1316+ foreach (glob ($ allowedDependenciesFilePattern ) as $ fileName ) {
1317+ $ allowedDependencies [] = include $ fileName ;
1318+ }
1319+ self ::$ allowedDependencies = array_merge ([], ...$ allowedDependencies );
1320+ }
1321+ return self ::$ allowedDependencies ;
1322+ }
12931323}
0 commit comments