~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to lib/tests/ajaxlib_test.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
defined('MOODLE_INTERNAL') || die();
27
27
 
28
28
class core_ajaxlib_testcase extends advanced_testcase {
 
29
    /** @var string Original error log */
 
30
    protected $oldlog;
 
31
 
 
32
    protected function setUp() {
 
33
        global $CFG;
 
34
 
 
35
        parent::setUp();
 
36
        // Discard error logs.
 
37
        $this->oldlog = ini_get('error_log');
 
38
        ini_set('error_log', "$CFG->dataroot/testlog.log");
 
39
    }
 
40
 
 
41
    protected function tearDown() {
 
42
        ini_set('error_log', $this->oldlog);
 
43
        parent::tearDown();
 
44
    }
29
45
 
30
46
    protected function helper_test_clean_output() {
31
47
        $this->resetAfterTest();
63
79
    }
64
80
 
65
81
    public function test_output_capture_normal_debug_none() {
66
 
        global $CFG;
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();
70
85
    }
71
86
 
72
87
    public function test_output_capture_normal_debug_normal() {
73
 
        global $CFG;
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();
77
91
    }
78
92
 
79
93
    public function test_output_capture_normal_debug_all() {
80
 
        global $CFG;
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();
84
97
    }
85
98
 
86
99
    public function test_output_capture_normal_debugdeveloper() {
87
 
        global $CFG;
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();
91
103
    }
92
104
 
93
105
    public function test_output_capture_error_debug_none() {
94
 
        global $CFG;
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();
98
109
    }
99
110
 
100
111
    public function test_output_capture_error_debug_normal() {
101
 
        global $CFG;
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();
105
115
    }
106
116
 
107
117
    public function test_output_capture_error_debug_all() {
108
 
        global $CFG;
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();
112
121
    }
113
122
 
114
123
    public function test_output_capture_error_debugdeveloper() {
115
 
        global $CFG;
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);
119
127
    }
120
128