You are here

public function SimpleTestErrorCollectorTest::testErrorCollect in SimpleTest 8.3

Tests that simpletest collects errors from the tested site.

File

src/Tests/SimpleTestErrorCollectorTest.php, line 35

Class

SimpleTestErrorCollectorTest
Tests SimpleTest error and exception collector.

Namespace

Drupal\simpletest\Tests

Code

public function testErrorCollect() {
  $this->collectedErrors = [];
  $this
    ->drupalGet('error-test/generate-warnings-with-report');
  $this
    ->assertEqual(count($this->collectedErrors), 3, 'Three errors were collected');
  if (count($this->collectedErrors) == 3) {
    $this
      ->assertError($this->collectedErrors[0], 'Notice', 'Drupal\\error_test\\Controller\\ErrorTestController->generateWarnings()', 'ErrorTestController.php', 'Undefined variable: bananas');
    $this
      ->assertError($this->collectedErrors[1], 'Warning', 'Drupal\\error_test\\Controller\\ErrorTestController->generateWarnings()', 'ErrorTestController.php', 'Division by zero');
    $this
      ->assertError($this->collectedErrors[2], 'User warning', 'Drupal\\error_test\\Controller\\ErrorTestController->generateWarnings()', 'ErrorTestController.php', 'Drupal & awesome');
  }
  else {

    // Give back the errors to the log report.
    foreach ($this->collectedErrors as $error) {
      parent::error($error['message'], $error['group'], $error['caller']);
    }
  }
}