You are here

public function ServiceTest::testToMessageList in Purge 8.3

Tests DiagnosticsService::toMessageList.

File

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

Class

ServiceTest
Tests DiagnosticsService.

Namespace

Drupal\Tests\purge\Kernel\DiagnosticCheck

Code

public function testToMessageList() : void {
  $this
    ->initializeRequirementSeverities();
  $this
    ->initializeService();
  $list = $this->service
    ->toMessageList($this->service);
  $this
    ->assertTrue(is_array($list));
  $this
    ->assertEquals(4, count($list));
  $this
    ->assertTrue(isset($list['info']));
  $this
    ->assertTrue(isset($list['ok']));
  $this
    ->assertTrue(isset($list['warning']));
  $this
    ->assertTrue(isset($list['error']));
  $this
    ->assertEquals(1, count($list['info']));
  $this
    ->assertEquals(3, count($list['ok']));
  $this
    ->assertEquals(6, count($list['warning']));
  $this
    ->assertEquals(2, count($list['error']));
  foreach ($list as $type => $msgs) {
    $this
      ->assertTrue(in_array($type, [
      'info',
      'ok',
      'warning',
      'error',
    ]));
    $this
      ->assertTrue(is_array($msgs));
    foreach ($msgs as $msg) {
      $this
        ->assertTrue(is_string($msg) && strlen($msg));
    }
  }
}