function PhpRequirementsTest::testPhpEolDates
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Utility/PhpRequirementsTest.php \Drupal\Tests\Core\Utility\PhpRequirementsTest::testPhpEolDates()
- 10 core/tests/Drupal/Tests/Core/Utility/PhpRequirementsTest.php \Drupal\Tests\Core\Utility\PhpRequirementsTest::testPhpEolDates()
Ensures that PHP EOL dates are valid.
This ensures that that all of the PHP EOL Date items are valid ISO 8601 dates and are keyed by a valid version number.
File
-
core/
tests/ Drupal/ Tests/ Core/ Utility/ PhpRequirementsTest.php, line 24
Class
- PhpRequirementsTest
- Tests the \Drupal\Core\Utility\PhpRequirements class.
Namespace
Drupal\Tests\Core\UtilityCode
public function testPhpEolDates() : void {
$reflected = new \ReflectionClass(PhpRequirements::class);
$php_eol_dates = $reflected->getStaticPropertyValue('phpEolDates');
foreach ($php_eol_dates as $version => $eol_date) {
// Ensure that all of the version numbers are defined in a superset of
// semver: 'major.minor.patch-modifier', where (unlike in semver) all
// parts but the major are optional.
// @see version_compare()
$this->assertMatchesRegularExpression('/^([0-9]+)(\\.([0-9]+)(\\.([0-9]+)(-[A-Za-z0-9]+)?)?)?$/', $version);
// Ensure that all of the EOL dates are defined using ISO 8601 format.
$this->assertMatchesRegularExpression('/^([0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])$/', $eol_date);
}
// Ensure that the EOL list is sorted in an ascending order by the date. If
// there are multiple versions EOL on the same day, sort by the PHP
// version.
uksort($php_eol_dates, function ($a, $b) use ($php_eol_dates) {
$a_date = strtotime($php_eol_dates[$a]);
$b_date = strtotime($php_eol_dates[$b]);
if ($a_date === $b_date) {
return $a <=> $b;
}
return $a_date <=> $b_date;
});
$this->assertSame($php_eol_dates, $reflected->getStaticPropertyValue('phpEolDates'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.