You are here

public function CheckTest::testStoreResult in Security Review 8

Tests the storing of a check result on every test check.

File

tests/src/Kernel/CheckTest.php, line 88

Class

CheckTest
Contains tests for Checks.

Namespace

Drupal\Tests\security_review\Kernel

Code

public function testStoreResult() {
  foreach ($this->testChecks as $check) {

    // Run the check and store its result.
    $result = $check
      ->run();
    $check
      ->storeResult($result);

    // Compare lastResult() with $result.
    $last_result = $check
      ->lastResult(TRUE);
    $this
      ->assertEquals($result
      ->result(), $last_result
      ->result(), 'Result stored.');
    $this
      ->assertEquals($result
      ->time(), $last_result
      ->time(), 'Time stored.');
    if ($check
      ->storesFindings()) {

      // If storesFindings() is set to FALSE, then these could differ.
      $this
        ->assertEquals($result
        ->findings(), $last_result
        ->findings(), 'Findings stored.');
    }
  }
}