From 8d37c9b2d9836e99112dbcf6a39f7899184b1e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Fri, 8 Feb 2013 01:25:31 +0100 Subject: [PATCH] MDL-37919 Let PHPUnit display the content of $a even if the error string is not found --- lib/setuplib.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/setuplib.php b/lib/setuplib.php index 88fd5fdad3d2c..d3b8a7e8c036c 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -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); } }