@@ -188,6 +188,16 @@ class DependencyTest extends \PHPUnit\Framework\TestCase
188
188
*/
189
189
private $ undeclaredDependencyBlacklist ;
190
190
191
+ /**
192
+ * @var array|null
193
+ */
194
+ private static $ extensionConflicts = null ;
195
+
196
+ /**
197
+ * @var array|null
198
+ */
199
+ private static $ allowedDependencies = null ;
200
+
191
201
/**
192
202
* Sets up data
193
203
*
@@ -1214,26 +1224,8 @@ public function testDirectExtensionDependencies()
1214
1224
{
1215
1225
$ invoker = new \Magento \Framework \App \Utility \AggregateInvoker ($ this );
1216
1226
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 ();
1237
1229
1238
1230
$ invoker (
1239
1231
/**
@@ -1290,4 +1282,42 @@ function ($fileType, $file) use ($extensionConflictList, $allowedDependencies) {
1290
1282
$ this ->getAllFiles ()
1291
1283
);
1292
1284
}
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
+ }
1293
1323
}
0 commit comments