SupportedPhpVersionTest.php in Automatic Updates 8
File
tests/src/Kernel/ReadinessChecker/SupportedPhpVersionTest.php
View source
<?php
namespace Drupal\Tests\automatic_updates\Kernel\ReadinessChecker;
use Drupal\automatic_updates\ReadinessChecker\BlacklistPhp72Versions;
use Drupal\automatic_updates\ReadinessChecker\MinimumPhpVersion;
use Drupal\KernelTests\KernelTestBase;
class SupportedPhpVersionTest extends KernelTestBase {
public static $modules = [
'automatic_updates',
];
public function testSupportedPhpVersion() {
$services = [
'automatic_updates.minimum_php_version',
'automatic_updates.blacklist_php_72',
];
foreach ($services as $service) {
$messages = $this->container
->get($service)
->run();
$this
->assertEmpty($messages);
}
$this
->assertNotEmpty($services);
$messages = (new TestBlacklistPhp72Versions())
->run();
self::assertEquals('PHP 7.2.0, 7.2.1 and 7.2.2 have issues with opcache that breaks signature validation. Please upgrade to a newer version of PHP to ensure assurance and security for package signing.', $messages[0]);
$messages = (new TestMinimumPhpVersion())
->run();
self::assertEquals('This site is running on an unsupported version of PHP. It cannot be updated. Please update to at least PHP 7.0.8.', $messages[0]);
}
}
class TestBlacklistPhp72Versions extends BlacklistPhp72Versions {
protected function getPhpVersion() {
return '7.2.0';
}
}
class TestMinimumPhpVersion extends MinimumPhpVersion {
protected function getPhpVersion() {
return '7.0.7';
}
}