Skip to content

Commit

Permalink
MDL-37919 Let PHPUnit display the content of $a even if the error str…
Browse files Browse the repository at this point in the history
…ing is not found
  • Loading branch information
mudrd8mz committed Feb 8, 2013
1 parent 1918a24 commit 8d37c9b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/setuplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,23 @@ function __construct($errorcode, $module='', $link='', $a=NULL, $debuginfo=null)

if (get_string_manager()->string_exists($errorcode, $module)) {
$message = get_string($errorcode, $module, $a);
$haserrorstring = true;
} else {
$message = $module . '/' . $errorcode;
$haserrorstring = false;
}

if (defined('PHPUNIT_TEST') and PHPUNIT_TEST and $debuginfo) {
$message = "$message ($debuginfo)";
}

if (!$haserrorstring and defined('PHPUNIT_TEST') and PHPUNIT_TEST) {
// Append the contents of $a to $debuginfo so helpful information isn't lost.
// This emulates what {@link get_exception_info()} does. Unfortunately that
// function is not used by phpunit.
$message .= PHP_EOL.'$a contents: '.print_r($a, true);
}

parent::__construct($message, 0);
}
}
Expand Down

0 comments on commit 8d37c9b

Please sign in to comment.