Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 24... Línea 24...
24
 * @author     Jay Churchward (jay@brickfieldlabs.ie)
24
 * @author     Jay Churchward (jay@brickfieldlabs.ie)
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
26
 */
27
class scheduler_test extends \advanced_testcase {
27
class scheduler_test extends \advanced_testcase {
Línea 28... Línea 28...
28
 
28
 
29
    public function test_request_analysis() {
29
    public function test_request_analysis(): void {
Línea 30... Línea 30...
30
        $this->resetAfterTest();
30
        $this->resetAfterTest();
31
 
31
 
32
        // I believe there is a bug where the code won't work with the default constructor values.
32
        // I believe there is a bug where the code won't work with the default constructor values.
Línea 46... Línea 46...
46
        $output = $object->request_analysis();
46
        $output = $object->request_analysis();
47
        $this->assertTrue($output);
47
        $this->assertTrue($output);
Línea 48... Línea 48...
48
 
48
 
Línea 49... Línea 49...
49
    }
49
    }
50
 
50
 
51
    public function test_mark_analyzed() {
51
    public function test_mark_analyzed(): void {
52
        $this->resetAfterTest();
52
        $this->resetAfterTest();
53
        $object = new scheduler();
53
        $object = new scheduler();
Línea 54... Línea 54...
54
        $output = $object->mark_analyzed();
54
        $output = $object->mark_analyzed();
55
        $this->assertTrue($output);
55
        $this->assertTrue($output);
56
 
56
 
57
        $object = new scheduler(1, 1);
57
        $object = new scheduler(1, 1);
Línea 58... Línea 58...
58
        $output = $object->mark_analyzed();
58
        $output = $object->mark_analyzed();
59
        $this->assertTrue($output);
59
        $this->assertTrue($output);
Línea 60... Línea 60...
60
    }
60
    }
61
 
61
 
62
    public function test_create_schedule() {
62
    public function test_create_schedule(): void {
Línea 74... Línea 74...
74
        $record = $DB->get_record($object::DATA_TABLE, ['contextlevel' => 1]);
74
        $record = $DB->get_record($object::DATA_TABLE, ['contextlevel' => 1]);
75
        $this->assertTrue($output);
75
        $this->assertTrue($output);
76
        $this->assertEquals($record->instanceid, 1);
76
        $this->assertEquals($record->instanceid, 1);
77
    }
77
    }
Línea 78... Línea 78...
78
 
78
 
79
    public function test_delete_schedule() {
79
    public function test_delete_schedule(): void {
Línea 80... Línea 80...
80
        global $DB;
80
        global $DB;
81
 
81
 
82
        // Call create_record() to insert a record into the table.
82
        // Call create_record() to insert a record into the table.
Línea 93... Línea 93...
93
        $record = $DB->get_record($object::DATA_TABLE, ['contextlevel' => 50]);
93
        $record = $DB->get_record($object::DATA_TABLE, ['contextlevel' => 50]);
94
        $this->assertTrue($output);
94
        $this->assertTrue($output);
95
        $this->assertFalse($record);
95
        $this->assertFalse($record);
96
    }
96
    }
Línea 97... Línea 97...
97
 
97
 
98
    public function test_is_in_schedule() {
98
    public function test_is_in_schedule(): void {
Línea 99... Línea 99...
99
        $this->resetAfterTest();
99
        $this->resetAfterTest();
100
 
100
 
101
        // This should assert to false as no record has been inserted.
101
        // This should assert to false as no record has been inserted.
Línea 107... Línea 107...
107
        $object->create_schedule();
107
        $object->create_schedule();
108
        $output = $object->is_in_schedule();
108
        $output = $object->is_in_schedule();
109
        $this->assertTrue($output);
109
        $this->assertTrue($output);
110
    }
110
    }
Línea 111... Línea 111...
111
 
111
 
112
    public function test_is_scheduled() {
112
    public function test_is_scheduled(): void {
Línea 113... Línea 113...
113
        $this->resetAfterTest();
113
        $this->resetAfterTest();
114
 
114
 
115
        // This should assert to false as no record has been inserted.
115
        // This should assert to false as no record has been inserted.
Línea 127... Línea 127...
127
        $object->request_analysis();
127
        $object->request_analysis();
128
        $output = $object->is_scheduled();
128
        $output = $object->is_scheduled();
129
        $this->assertTrue($output);
129
        $this->assertTrue($output);
130
    }
130
    }
Línea 131... Línea 131...
131
 
131
 
132
    public function test_is_submitted() {
132
    public function test_is_submitted(): void {
Línea 133... Línea 133...
133
        $this->resetAfterTest();
133
        $this->resetAfterTest();
134
 
134
 
135
        // This should assert to false as no record has been inserted.
135
        // This should assert to false as no record has been inserted.
Línea 147... Línea 147...
147
        $object->mark_analyzed();
147
        $object->mark_analyzed();
148
        $output = $object->is_submitted();
148
        $output = $object->is_submitted();
149
        $this->assertTrue($output);
149
        $this->assertTrue($output);
150
    }
150
    }
Línea 151... Línea 151...
151
 
151
 
152
    public function test_is_analyzed() {
152
    public function test_is_analyzed(): void {
Línea 153... Línea 153...
153
        $this->resetAfterTest();
153
        $this->resetAfterTest();
154
 
154
 
155
        // This should assert to false as no record has been inserted.
155
        // This should assert to false as no record has been inserted.
Línea 168... Línea 168...
168
        $output = $object->is_analyzed();
168
        $output = $object->is_analyzed();
169
        $this->assertTrue($output);
169
        $this->assertTrue($output);
170
    }
170
    }
Línea 171... Línea 171...
171
 
171
 
172
    // Can't test because it's a protected function.
172
    // Can't test because it's a protected function.
173
    public function test_standard_search_params() {
173
    public function test_standard_search_params(): void {
Línea 174... Línea 174...
174
    }
174
    }
175
 
175
 
176
    // Can't test because it's a protected function.
176
    // Can't test because it's a protected function.
Línea 177... Línea 177...
177
    public function test_get_contextid() {
177
    public function test_get_contextid(): void {
178
    }
178
    }
Línea 179... Línea 179...
179
 
179
 
180
    public function test_get_datarecord() {
180
    public function test_get_datarecord(): void {
181
        $this->resetAfterTest();
181
        $this->resetAfterTest();
Línea 198... Línea 198...
198
        $this->assertEquals($output->instanceid, 10);
198
        $this->assertEquals($output->instanceid, 10);
199
        $this->assertEquals($output->status, 5);
199
        $this->assertEquals($output->status, 5);
200
    }
200
    }
Línea 201... Línea 201...
201
 
201
 
202
    // No return statement.
202
    // No return statement.
Línea 203... Línea 203...
203
    public function test_process_scheduled_requests() {
203
    public function test_process_scheduled_requests(): void {
Línea 204... Línea 204...
204
 
204
 
205
    }
205
    }
206
 
206
 
Línea 207... Línea 207...
207
    public function test_initialize_schedule() {
207
    public function test_initialize_schedule(): void {
208
        global $DB;
208
        global $DB;
Línea 217... Línea 217...
217
        $record = $DB->get_record(scheduler::DATA_TABLE, ['contextlevel' => 20]);
217
        $record = $DB->get_record(scheduler::DATA_TABLE, ['contextlevel' => 20]);
218
        $this->assertTrue($output);
218
        $this->assertTrue($output);
219
        $this->assertEquals($record->contextlevel, 20);
219
        $this->assertEquals($record->contextlevel, 20);
220
    }
220
    }
Línea 221... Línea 221...
221
 
221
 
222
    public function test_request_course_analysis() {
222
    public function test_request_course_analysis(): void {
Línea 223... Línea 223...
223
        $this->resetAfterTest();
223
        $this->resetAfterTest();
224
 
224
 
225
        $output = scheduler::request_course_analysis(1);
225
        $output = scheduler::request_course_analysis(1);
Línea 226... Línea 226...
226
        $this->assertTrue($output);
226
        $this->assertTrue($output);
227
    }
227
    }
228
 
228
 
Línea 229... Línea 229...
229
    public function test_create_course_schedule() {
229
    public function test_create_course_schedule(): void {
230
        global $DB;
230
        global $DB;
231
        $this->resetAfterTest();
231
        $this->resetAfterTest();
232
 
232
 
Línea 233... Línea 233...
233
        $output = scheduler::create_course_schedule(1);
233
        $output = scheduler::create_course_schedule(1);
Línea 234... Línea 234...
234
        $record = $DB->get_record(scheduler::DATA_TABLE, ['contextlevel' => 50]);
234
        $record = $DB->get_record(scheduler::DATA_TABLE, ['contextlevel' => 50]);
235
        $this->assertTrue($output);
235
        $this->assertTrue($output);
236
        $this->assertEquals($record->instanceid, 1);
236
        $this->assertEquals($record->instanceid, 1);
Línea 237... Línea 237...
237
 
237
 
238
    }
238
    }
Línea 249... Línea 249...
249
        $record = $DB->get_record(scheduler::DATA_TABLE, ['contextlevel' => 50]);
249
        $record = $DB->get_record(scheduler::DATA_TABLE, ['contextlevel' => 50]);
250
        $this->assertTrue($output);
250
        $this->assertTrue($output);
251
        $this->assertFalse($record);
251
        $this->assertFalse($record);
252
    }
252
    }
Línea 253... Línea 253...
253
 
253
 
254
    public function test_is_course_in_schedule() {
254
    public function test_is_course_in_schedule(): void {
Línea 255... Línea 255...
255
        $this->resetAfterTest();
255
        $this->resetAfterTest();
256
 
256
 
257
        // This should assert to false as no record has been inserted.
257
        // This should assert to false as no record has been inserted.
Línea 262... Línea 262...
262
        scheduler::create_course_schedule(1);
262
        scheduler::create_course_schedule(1);
263
        $output = scheduler::is_course_in_schedule(1);
263
        $output = scheduler::is_course_in_schedule(1);
264
        $this->assertTrue($output);
264
        $this->assertTrue($output);
265
    }
265
    }
Línea 266... Línea 266...
266
 
266
 
267
    public function test_is_course_scheduled() {
267
    public function test_is_course_scheduled(): void {
Línea 268... Línea 268...
268
        $this->resetAfterTest();
268
        $this->resetAfterTest();
269
 
269
 
270
        // This should assert to false as no record has been inserted.
270
        // This should assert to false as no record has been inserted.
Línea 281... Línea 281...
281
        scheduler::request_course_analysis(1);
281
        scheduler::request_course_analysis(1);
282
        $output = scheduler::is_course_scheduled(1);
282
        $output = scheduler::is_course_scheduled(1);
283
        $this->assertTrue($output);
283
        $this->assertTrue($output);
284
    }
284
    }
Línea 285... Línea 285...
285
 
285
 
286
    public function test_is_course_analyzed() {
286
    public function test_is_course_analyzed(): void {
287
        $this->resetAfterTest();
287
        $this->resetAfterTest();
Línea 288... Línea 288...
288
        $object = new scheduler(10, 1);
288
        $object = new scheduler(10, 1);
289
 
289