function SimpleTestErrorCollectorTest::testErrorCollect

Tests that simpletest collects errors from the tested site.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Common/SimpleTestErrorCollectorTest.php, line 45
Definition of Drupal\system\Tests\Common\SimpleTestErrorCollectorTest.

Class

SimpleTestErrorCollectorTest
Tests SimpleTest error and exception collector.

Namespace

Drupal\system\Tests\Common

Code

function testErrorCollect() {
  $this->collectedErrors = array();
  $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', 'error_test_generate_warnings()', 'error_test.module', 'Undefined variable: bananas');
    $this
      ->assertError($this->collectedErrors[1], 'Warning', 'error_test_generate_warnings()', 'error_test.module', 'Division by zero');
    $this
      ->assertError($this->collectedErrors[2], 'User warning', 'error_test_generate_warnings()', 'error_test.module', 'Drupal is awesome');
  }
  else {

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