You are here

public function SimpleTestTest::assertAssertion in Drupal 8

Asserts that an assertion with specified values is displayed in results.

Parameters

string $message: Assertion message.

string $type: Assertion type.

string $status: Assertion status.

string $file: File where the assertion originated.

string $function: Function where the assertion originated.

Return value

Assertion result.

1 call to SimpleTestTest::assertAssertion()
SimpleTestTest::confirmStubTestResults in core/modules/simpletest/src/Tests/SimpleTestTest.php
Confirm that the stub test produced the desired results.

File

core/modules/simpletest/src/Tests/SimpleTestTest.php, line 305

Class

SimpleTestTest
Tests SimpleTest's web interface: check that the intended tests were run and ensure that test reports display the intended results. Also test SimpleTest's internal browser and APIs implicitly.

Namespace

Drupal\simpletest\Tests

Code

public function assertAssertion($message, $type, $status, $file, $function) {
  $message = trim(strip_tags($message));
  $found = FALSE;
  foreach ($this->childTestResults['assertions'] as $assertion) {
    if (strpos($assertion['message'], $message) !== FALSE && $assertion['type'] == $type && $assertion['status'] == $status && $assertion['file'] == $file && $assertion['function'] == $function) {
      $found = TRUE;
      break;
    }
  }
  return $this
    ->assertTrue($found, new FormattableMarkup('Found assertion {"@message", "@type", "@status", "@file", "@function"}.', [
    '@message' => $message,
    '@type' => $type,
    '@status' => $status,
    "@file" => $file,
    "@function" => $function,
  ]));
}