You are here

public function ServiceTest::testFilters in Purge 8.3

Tests the various ::filter* methods.

Covers: \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::filterInfo \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::filterOk \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::filterWarnings \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::filterWarningAndErrors \Drupal\purge\Plugin\Purge\DiagnosticCheck\DiagnosticsService::filterErrors.

File

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

Class

ServiceTest
Tests DiagnosticsService.

Namespace

Drupal\Tests\purge\Kernel\DiagnosticCheck

Code

public function testFilters() : void {
  $this
    ->initializeService();
  $this
    ->assertTrue($this->service
    ->filterInfo() instanceof \Iterator);
  $this
    ->assertTrue($this->service
    ->filterInfo() instanceof \Countable);
  $this
    ->assertTrue($this->service
    ->filterOk() instanceof \Iterator);
  $this
    ->assertTrue($this->service
    ->filterOk() instanceof \Countable);
  $this
    ->assertTrue($this->service
    ->filterWarnings() instanceof \Iterator);
  $this
    ->assertTrue($this->service
    ->filterWarnings() instanceof \Countable);
  $this
    ->assertTrue($this->service
    ->filterWarningAndErrors() instanceof \Iterator);
  $this
    ->assertTrue($this->service
    ->filterWarningAndErrors() instanceof \Countable);
  $this
    ->assertTrue($this->service
    ->filterErrors() instanceof \Iterator);
  $this
    ->assertTrue($this->service
    ->filterErrors() instanceof \Countable);
  $this
    ->assertEquals(1, count($this->service
    ->filterInfo()));
  foreach ($this->service
    ->filterInfo() as $check) {
    $this
      ->assertTrue($check instanceof DiagnosticCheckInterface);
  }
  $this
    ->assertEquals(3, count($this->service
    ->filterOk()));
  foreach ($this->service
    ->filterOk() as $check) {
    $this
      ->assertTrue($check instanceof DiagnosticCheckInterface);
  }
  $this
    ->assertEquals(6, count($this->service
    ->filterWarnings()));
  foreach ($this->service
    ->filterWarnings() as $check) {
    $this
      ->assertTrue($check instanceof DiagnosticCheckInterface);
  }
  $this
    ->assertEquals(8, count($this->service
    ->filterWarningAndErrors()));
  foreach ($this->service
    ->filterWarningAndErrors() as $check) {
    $this
      ->assertTrue($check instanceof DiagnosticCheckInterface);
  }
  $this
    ->assertEquals(2, count($this->service
    ->filterErrors()));
  foreach ($this->service
    ->filterErrors() as $check) {
    $this
      ->assertTrue($check instanceof DiagnosticCheckInterface);
  }
}