function DrupalErrorCollectionUnitTest::testErrorCollect

Test that simpletest collects errors from the tested site.

File

modules/simpletest/tests/common.test, line 2769

Class

DrupalErrorCollectionUnitTest
Tests Simpletest error and exception collector.

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', 'Object of class stdClass could not be converted to int');
        $this->assertError($this->collectedErrors[1], 'Warning', 'error_test_generate_warnings()', 'error_test.module', \PHP_VERSION_ID < 80000 ? 'Invalid argument supplied for foreach()' : 'foreach() argument must be of type array|object, string given');
        $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']);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.