You are here

public function HookRequirementsTest::testHookRequirements in Purge 8.3

Tests that purge_requirements() passes on our diagnostic checks.

File

tests/src/Kernel/DiagnosticCheck/HookRequirementsTest.php, line 27

Class

HookRequirementsTest
Tests that purge_requirements() passes on our diagnostic checks.

Namespace

Drupal\Tests\purge\Kernel\DiagnosticCheck

Code

public function testHookRequirements() : void {
  $module_handler = \Drupal::service('module_handler');
  $module_handler
    ->loadInclude('purge', 'install');
  $req = $module_handler
    ->invoke('purge', 'requirements', [
    'runtime',
  ]);

  // Assert presence of all DiagnosticCheck plugins we know off.
  $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"]));

  // Assert check titles.
  $this
    ->assertSame('Purge: Always a warning', $req['alwayswarning']['title']);
  $this
    ->assertSame('Purge: Always an error', $req['alwayserror']['title']);

  // Assert that the descriptions come through.
  $this
    ->assertSame('This is a warning for testing.', $req['alwayswarning']['description']);
  $this
    ->assertSame('This is an error for testing.', $req['alwayserror']['description']);

  // Assert that the severities come through properly.
  $this
    ->assertSame(1, $req['alwayswarning']['severity']);
  $this
    ->assertSame(2, $req['alwayserror']['severity']);

  // Assert that the severity statuses come through properly.
  $this
    ->assertSame('warning', $req['alwayswarning']['severity_status']);
  $this
    ->assertSame('error', $req['alwayserror']['severity_status']);

  // Assert that the values come through properly.
  $this
    ->assertSame(TRUE, is_string($req['capacity']['value']));
  $this
    ->assertSame("0", $req['capacity']['value']);
}