Skip to content

Commit c8cd9e5

Browse files
committed
MC-5421: Create test to check dependencies between modules in Declarative Schema
1 parent 3afa2ea commit c8cd9e5

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ class DeclarativeDependencyTest extends \PHPUnit\Framework\TestCase
2222
*/
2323
private $dependencyProvider;
2424

25+
/**
26+
* @var array
27+
*/
28+
private $blacklistedDependencies = [];
29+
2530
/**
2631
* Sets up data
2732
*
@@ -45,6 +50,14 @@ protected function setUp()
4550
*/
4651
public function testUndeclaredDependencies()
4752
{
53+
/** TODO: Remove this temporary solution after MC-15534 is closed */
54+
$filePattern = __DIR__ . '/_files/dependency_test/blacklisted_dependencies_*.php';
55+
$blacklistedDependencies = [];
56+
foreach (glob($filePattern) as $fileName) {
57+
$blacklistedDependencies = array_merge($blacklistedDependencies, require $fileName);
58+
}
59+
$this->blacklistedDependencies = $blacklistedDependencies;
60+
4861
$invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
4962
$invoker(
5063
/**
@@ -71,7 +84,9 @@ function ($file) {
7184
$result = [];
7285
foreach ($undeclaredDependency as $name => $modules) {
7386
$modules = array_unique($modules);
74-
$result[] = $this->getErrorMessage($name) . "\n" . implode("\t\n", $modules);
87+
if ($this->filterBlacklistedDependencies($foundModuleName, $modules)) {
88+
$result[] = $this->getErrorMessage($name) . "\n" . implode("\t\n", $modules);
89+
}
7590
}
7691
if (count($result)) {
7792
$this->fail(
@@ -83,6 +98,24 @@ function ($file) {
8398
);
8499
}
85100

101+
/**
102+
* Filter blacklisted dependencies.
103+
*
104+
* @todo Remove this temporary solution after MC-15534 is closed
105+
*
106+
* @param string $moduleName
107+
* @param array $dependencies
108+
* @return array
109+
*/
110+
private function filterBlacklistedDependencies(string $moduleName, array $dependencies): array
111+
{
112+
if (!empty($this->blacklistedDependencies[$moduleName])) {
113+
$dependencies = array_diff($dependencies, $this->blacklistedDependencies[$moduleName]);
114+
}
115+
116+
return $dependencies;
117+
}
118+
86119
/**
87120
* Convert file list to data provider structure.
88121
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
return [
8+
"Magento\InventorySales" => ["Magento\Inventory"],
9+
];

0 commit comments

Comments
 (0)