Skip to content

Commit 5b92f7b

Browse files
committed
MAGETWO-89412: [2.3] Composer static test of PHP versions is failed for non-core modules
1 parent 14f7b06 commit 5b92f7b

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

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

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,17 @@ private function assertMagentoConventions($dir, $packageType, \StdClass $json)
210210
}
211211
}
212212

213+
/**
214+
* Checks if package vendor is Magento.
215+
*
216+
* @param string $packageName
217+
* @return bool
218+
*/
219+
private function isVendorMagento(string $packageName)
220+
{
221+
return strpos($packageName, 'magento/') === 0;
222+
}
223+
213224
/**
214225
* Assert that component registrar is autoloaded in composer json
215226
*
@@ -313,12 +324,24 @@ private function assertDependsOnFramework(\StdClass $json)
313324
private function assertPhpVersionInSync($name, $phpVersion)
314325
{
315326
if (isset(self::$rootJson['require']['php'])) {
316-
$this->assertEquals(
317-
self::$rootJson['require']['php'],
318-
$phpVersion,
319-
"PHP version {$phpVersion} in component {$name} is inconsistent with version "
320-
. self::$rootJson['require']['php'] . ' in root composer.json'
321-
);
327+
if ($this->isVendorMagento($name)) {
328+
$this->assertEquals(
329+
self::$rootJson['require']['php'],
330+
$phpVersion,
331+
"PHP version {$phpVersion} in component {$name} is inconsistent with version "
332+
. self::$rootJson['require']['php'] . ' in root composer.json'
333+
);
334+
} else {
335+
$composerVersionsPattern = '{\s*\|\|?\s*}';
336+
$rootPhpVersions = preg_split($composerVersionsPattern, self::$rootJson['require']['php']);
337+
$modulePhpVersions = preg_split($composerVersionsPattern, $phpVersion);
338+
339+
$this->assertEmpty(
340+
array_diff($rootPhpVersions, $modulePhpVersions),
341+
"PHP version {$phpVersion} in component {$name} is inconsistent with version "
342+
. self::$rootJson['require']['php'] . ' in root composer.json'
343+
);
344+
}
322345
}
323346
}
324347

0 commit comments

Comments
 (0)