26
26
defined('MOODLE_INTERNAL') || die();
28
28
class core_ajaxlib_testcase extends advanced_testcase {
29
/** @var string Original error log */
32
protected function setUp() {
36
// Discard error logs.
37
$this->oldlog = ini_get('error_log');
38
ini_set('error_log', "$CFG->dataroot/testlog.log");
41
protected function tearDown() {
42
ini_set('error_log', $this->oldlog);
30
46
protected function helper_test_clean_output() {
31
47
$this->resetAfterTest();
65
81
public function test_output_capture_normal_debug_none() {
67
82
// In normal conditions, and with DEBUG_NONE set, we should not receive any output or throw any exceptions.
68
$CFG->debug = DEBUG_NONE;
83
set_debugging(DEBUG_NONE);
69
84
$this->helper_test_clean_output();
72
87
public function test_output_capture_normal_debug_normal() {
74
88
// In normal conditions, and with DEBUG_NORMAL set, we should not receive any output or throw any exceptions.
75
$CFG->debug = DEBUG_NORMAL;
89
set_debugging(DEBUG_NORMAL);
76
90
$this->helper_test_clean_output();
79
93
public function test_output_capture_normal_debug_all() {
81
94
// In normal conditions, and with DEBUG_ALL set, we should not receive any output or throw any exceptions.
82
$CFG->debug = DEBUG_ALL;
95
set_debugging(DEBUG_ALL);
83
96
$this->helper_test_clean_output();
86
99
public function test_output_capture_normal_debugdeveloper() {
88
100
// In normal conditions, and with DEBUG_DEVELOPER set, we should not receive any output or throw any exceptions.
89
$CFG->debug = DEBUG_DEVELOPER;
101
set_debugging(DEBUG_DEVELOPER);
90
102
$this->helper_test_clean_output();
93
105
public function test_output_capture_error_debug_none() {
95
106
// With DEBUG_NONE set, we should not throw any exception, but the output will be returned.
96
$CFG->debug = DEBUG_NONE;
107
set_debugging(DEBUG_NONE);
97
108
$this->helper_test_dirty_output();
100
111
public function test_output_capture_error_debug_normal() {
102
112
// With DEBUG_NORMAL set, we should not throw any exception, but the output will be returned.
103
$CFG->debug = DEBUG_NORMAL;
113
set_debugging(DEBUG_NORMAL);
104
114
$this->helper_test_dirty_output();
107
117
public function test_output_capture_error_debug_all() {
109
118
// In error conditions, and with DEBUG_ALL set, we should not receive any output or throw any exceptions.
110
$CFG->debug = DEBUG_ALL;
119
set_debugging(DEBUG_ALL);
111
120
$this->helper_test_dirty_output();
114
123
public function test_output_capture_error_debugdeveloper() {
116
124
// With DEBUG_DEVELOPER set, we should throw an exception.
117
$CFG->debug = DEBUG_DEVELOPER;
125
set_debugging(DEBUG_DEVELOPER);
118
126
$this->helper_test_dirty_output(true);