MDL-40842 behat: improved exception + debugging detection

This commit is contained in:
Sam Hemelryk 2013-07-24 11:18:19 +12:00
parent bdd045c5ec
commit 3e76c7fa68
5 changed files with 16 additions and 14 deletions

View File

@ -134,7 +134,7 @@ function behat_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
}
// Wrapping the output.
echo '<div class="phpdebugmessage">' . PHP_EOL;
echo '<div class="phpdebugmessage" data-rel="phpdebugmessage">' . PHP_EOL;
echo "$errnostr: $errstr in $errfile on line $errline" . PHP_EOL;
echo '</div>';

View File

@ -2405,7 +2405,7 @@ EOD;
$message .= '<p class="errormessage">' . get_string('installproblem', 'error') . '</p>';
//It is usually not possible to recover from errors triggered during installation, you may need to create a new database or use a different database prefix for new installation.
}
$output .= $this->box($message, 'errorbox');
$output .= $this->box($message, 'errorbox', array('data-rel' => 'fatalerror'));
if (debugging('', DEBUG_DEVELOPER)) {
if (!empty($debuginfo)) {
@ -2552,10 +2552,11 @@ EOD;
* @param string $contents The contents of the box
* @param string $classes A space-separated list of CSS classes
* @param string $id An optional ID
* @param array $attributes An array of other attributes to give the box.
* @return string the HTML to output.
*/
public function box($contents, $classes = 'generalbox', $id = null) {
return $this->box_start($classes, $id) . $contents . $this->box_end();
public function box($contents, $classes = 'generalbox', $id = null, $attributes = array()) {
return $this->box_start($classes, $id, $attributes) . $contents . $this->box_end();
}
/**
@ -2563,12 +2564,14 @@ EOD;
*
* @param string $classes A space-separated list of CSS classes
* @param string $id An optional ID
* @param array $attributes An array of other attributes to give the box.
* @return string the HTML to output.
*/
public function box_start($classes = 'generalbox', $id = null) {
public function box_start($classes = 'generalbox', $id = null, $attributes = array()) {
$this->opencontainers->push('box', html_writer::end_tag('div'));
return html_writer::start_tag('div', array('id' => $id,
'class' => 'box ' . renderer_base::prepare_classes($classes)));
$attributes['id'] = $id;
$attributes['class'] = 'box ' . renderer_base::prepare_classes($classes);
return html_writer::start_tag('div', $attributes);
}
/**

View File

@ -665,7 +665,7 @@ function format_backtrace($callers, $plaintext = false) {
return '';
}
$from = $plaintext ? '' : '<ul style="text-align: left">';
$from = $plaintext ? '' : '<ul style="text-align: left" data-rel="backtrace">';
foreach ($callers as $caller) {
if (!isset($caller['line'])) {
$caller['line'] = '?'; // probably call_user_func()

View File

@ -244,14 +244,13 @@ class behat_hooks extends behat_base {
try {
// Exceptions.
$exceptionsxpath = "//*[contains(concat(' ', normalize-space(@class), ' '), ' errorbox ')]" .
"/descendant::p[contains(concat(' ', normalize-space(@class), ' '), ' errormessage ')]";
$exceptionsxpath = "//div[@data-rel='fatalerror']";
// Debugging messages.
$debuggingxpath = "//*[contains(concat(' ', normalize-space(@class), ' '), ' debuggingmessage ')]";
$debuggingxpath = "//div[@data-rel='debugging']";
// PHP debug messages.
$phperrorxpath = "//*[contains(concat(' ', normalize-space(@class), ' '), ' phpdebugmessage ')]";
$phperrorxpath = "//div[@data-rel='phpdebugmessage']";
// Any other backtrace.
$othersxpath = "(//*[contains(., ': call to ')])[1]";
$othersxpath = "//ul[@data-rel='backtrace']";
$xpaths = array($exceptionsxpath, $debuggingxpath, $phperrorxpath, $othersxpath);
$joinedxpath = implode(' | ', $xpaths);

View File

@ -2820,7 +2820,7 @@ function debugging($message = '', $level = DEBUG_NORMAL, $backtrace = null) {
if (CLI_SCRIPT) {
echo "++ $message ++\n$from";
} else {
echo '<div class="notifytiny debuggingmessage">' . $message . $from . '</div>';
echo '<div class="notifytiny debuggingmessage" data-rel="debugging">' , $message , $from , '</div>';
}
} else {