View source
<?php
namespace Drupal\Tests\purge\Kernel\DiagnosticCheck;
use Drupal\Tests\purge\Kernel\KernelTestBase;
class HookRequirementsTest extends KernelTestBase {
public static $modules = [
'system',
'purge_check_test',
'purge_check_error_test',
'purge_check_warning_test',
];
public function testHookRequirements() : void {
$module_handler = \Drupal::service('module_handler');
$module_handler
->loadInclude('purge', 'install');
$req = $module_handler
->invoke('purge', 'requirements', [
'runtime',
]);
$this
->assertSame(TRUE, isset($req["capacity"]));
$this
->assertSame(TRUE, isset($req["maxage"]));
$this
->assertSame(TRUE, isset($req["memoryqueuewarning"]));
$this
->assertSame(TRUE, isset($req["page_cache"]));
$this
->assertSame(TRUE, isset($req["processorsavailable"]));
$this
->assertSame(TRUE, isset($req["purgersavailable"]));
$this
->assertSame(TRUE, isset($req["queuersavailable"]));
$this
->assertSame(TRUE, isset($req["alwayserror"]));
$this
->assertSame(TRUE, isset($req["alwayswarning"]));
$this
->assertSame(FALSE, isset($req["alwaysinfo"]));
$this
->assertSame(FALSE, isset($req["alwaysok"]));
$this
->assertSame(FALSE, isset($req["purgerwarning"]));
$this
->assertSame(FALSE, isset($req["queuewarning"]));
$this
->assertSame('Purge: Always a warning', $req['alwayswarning']['title']);
$this
->assertSame('Purge: Always an error', $req['alwayserror']['title']);
$this
->assertSame('This is a warning for testing.', $req['alwayswarning']['description']);
$this
->assertSame('This is an error for testing.', $req['alwayserror']['description']);
$this
->assertSame(1, $req['alwayswarning']['severity']);
$this
->assertSame(2, $req['alwayserror']['severity']);
$this
->assertSame('warning', $req['alwayswarning']['severity_status']);
$this
->assertSame('error', $req['alwayserror']['severity_status']);
$this
->assertSame(TRUE, is_string($req['capacity']['value']));
$this
->assertSame("0", $req['capacity']['value']);
}
}