Skip to content

Commit e5c6c87

Browse files
committed
MAGETWO-88890: Composer static test of PHP versions is failed for non-core modules
1 parent 975b90b commit e5c6c87

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
@@ -189,6 +189,17 @@ private function assertMagentoConventions($dir, $packageType, \StdClass $json)
189189
$this->assertPackageVersions($json);
190190
}
191191

192+
/**
193+
* Checks if package vendor is Magento.
194+
*
195+
* @param string $packageName
196+
* @return bool
197+
*/
198+
private function isVendorMagento($packageName)
199+
{
200+
return strpos($packageName, 'magento/') === 0;
201+
}
202+
192203
/**
193204
* Assert that component registrar is autoloaded in composer json
194205
*
@@ -276,12 +287,24 @@ private function assertDependsOnFramework(\StdClass $json)
276287
private function assertPhpVersionInSync($name, $phpVersion)
277288
{
278289
if (isset(self::$rootJson['require']['php'])) {
279-
$this->assertEquals(
280-
self::$rootJson['require']['php'],
281-
$phpVersion,
282-
"PHP version {$phpVersion} in component {$name} is inconsistent with version "
283-
. self::$rootJson['require']['php'] . ' in root composer.json'
284-
);
290+
if ($this->isVendorMagento($name)) {
291+
$this->assertEquals(
292+
self::$rootJson['require']['php'],
293+
$phpVersion,
294+
"PHP version {$phpVersion} in component {$name} is inconsistent with version "
295+
. self::$rootJson['require']['php'] . ' in root composer.json'
296+
);
297+
} else {
298+
$composerVersionsPattern = '{\s*\|\|?\s*}';
299+
$rootPhpVersions = preg_split($composerVersionsPattern, self::$rootJson['require']['php']);
300+
$modulePhpVersions = preg_split($composerVersionsPattern, $phpVersion);
301+
302+
$this->assertEmpty(
303+
array_diff($rootPhpVersions, $modulePhpVersions),
304+
"PHP version {$phpVersion} in component {$name} is inconsistent with version "
305+
. self::$rootJson['require']['php'] . ' in root composer.json'
306+
);
307+
}
285308
}
286309
}
287310

0 commit comments

Comments
 (0)