Skip to content

Commit 4bd485c

Browse files
committed
SEARCH-1968: Static tests to check for dependency of Elasticsearch modules.
1 parent 7974e39 commit 4bd485c

File tree

3 files changed

+85
-20
lines changed
  • dev/tests/static/testsuite/Magento/Test/Integrity

3 files changed

+85
-20
lines changed

dev/tests/static/testsuite/Magento/Test/Integrity/DependencyTest.php

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
return [
9+
'Magento\Elasticsearch' => [
10+
'Magento\Elasticsearch',
11+
'Magento\Elasticsearch6',
12+
'Magento\Elasticsearch7',
13+
'Magento\ElasticsearchCatalogPermissions', // move to EE repo
14+
'Magento\ElasticsearchCatalogPermissionsGraphQl', // move to EE repo
15+
]
16+
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
return [
9+
// the following modules must be disabled when Live Search is used
10+
// so core modules must not be dependent on them
11+
'Magento\LiveSearch' => [
12+
'Magento\Elasticsearch',
13+
'Magento\Elasticsearch6',
14+
'Magento\Elasticsearch7',
15+
'Magento\ElasticsearchCatalogPermissions',// move to EE repo
16+
'Magento\ElasticsearchCatalogPermissionsGraphQl', // move to EE repo
17+
'Magento\InventoryElasticSearch', // move to Inventory repo
18+
],
19+
];

0 commit comments

Comments
 (0)