Issue #3266525 by alexpott, quietone, xjm, daffie, longwave: MINIMUM_SUPPORTED_PHP is less than MINIMUM_PHP

merge-requests/1919/head
catch 2022-03-04 10:25:48 +00:00
parent 9e5dd04fac
commit c2495d1b0d
2 changed files with 26 additions and 1 deletions

View File

@ -96,7 +96,7 @@ class Drupal {
* that Drupal no longer supports that PHP version.
* - An error is shown in the status report that the PHP version is too old.
*/
const MINIMUM_SUPPORTED_PHP = '8.0.2';
const MINIMUM_SUPPORTED_PHP = '8.1.0';
/**
* Minimum allowed version of PHP for Drupal to be bootstrapped.

View File

@ -433,6 +433,31 @@ class DrupalTest extends UnitTestCase {
$this->assertNotNull(\Drupal::accessManager());
}
/**
* Tests the PHP constants have consistent values.
*/
public function testPhpConstants() {
// RECOMMENDED_PHP and MINIMUM_SUPPORTED_PHP can be just MAJOR.MINOR so
// normalize them so that version_compare() can be used.
$normalizer = function (string $version): string {
// The regex below is from \Composer\Semver\VersionParser::normalize().
preg_match('{^(\d{1,5})(\.\d++)?(\.\d++)?$}i', $version, $matches);
return $matches[1]
. (!empty($matches[2]) ? $matches[2] : '.9999999')
. (!empty($matches[3]) ? $matches[3] : '.9999999');
};
$minimum_supported_php = $normalizer(\Drupal::MINIMUM_SUPPORTED_PHP);
$recommended_php = $normalizer(\Drupal::RECOMMENDED_PHP);
$this->assertTrue(version_compare($minimum_supported_php, \Drupal::MINIMUM_PHP, '>='), "\Drupal::MINIMUM_SUPPORTED_PHP should be greater or equal to \Drupal::MINIMUM_PHP");
$this->assertTrue(version_compare($recommended_php, \Drupal::MINIMUM_SUPPORTED_PHP, '>='), "\Drupal::RECOMMENDED_PHP should be greater or equal to \Drupal::MINIMUM_SUPPORTED_PHP");
// As this test depends on the $normalizer function it is tested.
$this->assertSame('10.9999999.9999999', $normalizer('10'));
$this->assertSame('10.1.9999999', $normalizer('10.1'));
$this->assertSame('10.1.2', $normalizer('10.1.2'));
}
/**
* Sets up a mock expectation for the container get() method.
*