function SimpleTestErrorCollectorTest::error
Stores errors into an array.
This test class is trying to verify that simpletest correctly sees errors and warnings. However, it can't generate errors and warnings that propagate up to the testing framework itself, or these tests would always fail. So, this special copy of error() doesn't propagate the errors up the class hierarchy. It just stuffs them into a protected collectedErrors array for various assertions to inspect.
Parameters
$message: (optional) A message to display with the assertion. Do not translate messages: use \Drupal\Component\Render\FormattableMarkup to embed variables in the message text, not t(). If left blank, a default message will be displayed.
$group: (optional) The group this message is in, which is displayed in a column in test output. Use 'Debug' to indicate this is debugging output. Do not translate this string. Defaults to 'Other'; most tests do not override this default.
$caller: The caller of the error.
Return value
FALSE.
Overrides TestBase::error
File
-
core/
modules/ simpletest/ src/ Tests/ SimpleTestErrorCollectorTest.php, line 63
Class
- SimpleTestErrorCollectorTest
- Tests SimpleTest error and exception collector.
Namespace
Drupal\simpletest\TestsCode
protected function error($message = '', $group = 'Other', array $caller = NULL) {
// Due to a WTF elsewhere, simpletest treats debug() and verbose()
// messages as if they were an 'error'. But, we don't want to collect
// those here. This function just wants to collect the real errors (PHP
// notices, PHP fatal errors, etc.), and let all the 'errors' from the
// 'User notice' group bubble up to the parent classes to be handled (and
// eventually displayed) as normal.
if ($group == 'User notice') {
parent::error($message, $group, $caller);
}
else {
$this->collectedErrors[] = [
'message' => $message,
'group' => $group,
'caller' => $caller,
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.