You are here

public function ServiceTest::testToRequirementsArray in Purge 8.3

Tests DiagnosticsService::toRequirementsArray.

File

tests/src/Kernel/DiagnosticCheck/ServiceTest.php, line 258

Class

ServiceTest
Tests DiagnosticsService.

Namespace

Drupal\Tests\purge\Kernel\DiagnosticCheck

Code

public function testToRequirementsArray() : void {
  $this
    ->initializeRequirementSeverities();
  $this
    ->initializeService();

  // Test the standard output as Drupal expects it.
  $requirements = $this->service
    ->toRequirementsArray($this->service);
  $this
    ->assertEquals(12, count($requirements));
  foreach ($requirements as $id => $requirement) {
    $this
      ->assertTrue(is_string($id));
    $this
      ->assertFalse(empty($id));
    $this
      ->assertTrue(is_string($requirement['title']) || $requirement['title'] instanceof TranslatableMarkup);
    $this
      ->assertFalse(strpos($requirement['title'], 'Purge: ') === 0);
    $this
      ->assertFalse(empty($requirement['title']));
    $this
      ->assertTrue(is_string($requirement['description']) || $requirement['description'] instanceof TranslatableMarkup);
    $this
      ->assertFalse(empty($requirement['description']));
    $this
      ->assertTrue(in_array($requirement['severity_status'], $this->severityStatuses));
    $this
      ->assertTrue(in_array($requirement['severity'], $this->requirementSeverities));
  }

  // Test that the $prefix_title parameter works as expected.
  foreach ($this->service
    ->toRequirementsArray($this->service, TRUE) as $requirement) {
    $this
      ->assertTrue(strpos($requirement['title'], 'Purge: ') === 0);
  }
}