function DrupalTestCase::assertError in SimpleTest 5
Same name and namespace in other branches
- 6 drupal_test_case.php \DrupalTestCase::assertError()
Confirms that an error has occurred and optionally that the error text matches exactly.
Parameters
string $expected Expected error text or: false for no check. @param string $message Message to display. @return boolean True on pass @access public
File
- ./
drupal_test_case.php, line 655
Class
- DrupalTestCase
- Test case for typical Drupal tests. Extends WebTestCase for comfortable browser usage but also implements all UnitTestCase methods, I wish WebTestCase would do this.
Code
function assertError($expected = false, $message = "%s") {
$queue =& SimpleErrorQueue::instance();
if ($queue
->isEmpty()) {
$this
->fail(sprintf($message, "Expected error not found"));
return;
}
list($severity, $content, $file, $line, $globals) = $queue
->extract();
$severity = SimpleErrorQueue::getSeverityAsString($severity);
return $this
->assertTrue(!$expected || $expected == $content, "Expected [{$expected}] in PHP error [{$content}] severity [{$severity}] in [{$file}] line [{$line}]");
}