mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
unit tests: MDL-20398 spurious exceptions when $CFG->debugdisplay is false
This commit is contained in:
parent
eaf3fd7a45
commit
4f19b365b8
1 changed files with 7 additions and 2 deletions
|
@ -3136,7 +3136,7 @@ function get_docs_url($path) {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function debugging($message = '', $level = DEBUG_NORMAL, $backtrace = null) {
|
function debugging($message = '', $level = DEBUG_NORMAL, $backtrace = null) {
|
||||||
global $CFG;
|
global $CFG, $UNITTEST;
|
||||||
|
|
||||||
if (empty($CFG->debug) || $CFG->debug < $level) {
|
if (empty($CFG->debug) || $CFG->debug < $level) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -3151,7 +3151,12 @@ function debugging($message = '', $level = DEBUG_NORMAL, $backtrace = null) {
|
||||||
$backtrace = debug_backtrace();
|
$backtrace = debug_backtrace();
|
||||||
}
|
}
|
||||||
$from = format_backtrace($backtrace, CLI_SCRIPT);
|
$from = format_backtrace($backtrace, CLI_SCRIPT);
|
||||||
if ($CFG->debugdisplay) {
|
if ($CFG->debugdisplay || empty($UNITTEST->running)) {
|
||||||
|
// When the unit tests are running, any call to trigger_error
|
||||||
|
// is intercepted by the test framework and reported as an exception.
|
||||||
|
// Therefore, we cannot use trigger_error during unit tests.
|
||||||
|
// At the same time I do not think we should just discard those messages,
|
||||||
|
// so displaying them on-screen seems like the only option. (MDL-20398)
|
||||||
if (!defined('DEBUGGING_PRINTED')) {
|
if (!defined('DEBUGGING_PRINTED')) {
|
||||||
define('DEBUGGING_PRINTED', 1); // indicates we have printed something
|
define('DEBUGGING_PRINTED', 1); // indicates we have printed something
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue