You are here

protected function RequestSanitizerTest::assertError in Drupal 7

Asserts that the expected error has been logged.

Parameters

string $errstr: The error message.

int $errno: The severity level of the error.

string $label: The label to include with the message.

Return value

bool TRUE if the assertion succeeded, FALSE otherwise.

1 call to RequestSanitizerTest::assertError()
RequestSanitizerTest::requestSanitizationTest in modules/simpletest/tests/request_sanitizer.test
Tests RequestSanitizer class.

File

modules/simpletest/tests/request_sanitizer.test, line 236
Tests for the RequestSanitizer class.

Class

RequestSanitizerTest
Tests DrupalRequestSanitizer class.

Code

protected function assertError($errstr, $errno, $label) {
  $label = empty($label) ? '' : $label . ': ';
  foreach ($this->errors as $error) {
    if ($error['errstr'] === $errstr && $error['errno'] === $errno) {
      return $this
        ->pass($label . "Error with level {$errno} and message '{$errstr}' found");
    }
  }
  return $this
    ->fail($label . "Error with level {$errno} and message '{$errstr}' not found in " . var_export($this->errors, TRUE));
}