Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 200... Línea 200...
200
     */
200
     */
201
    protected function async_restore_to_new_course($backupid, $userid = 2) {
201
    protected function async_restore_to_new_course($backupid, $userid = 2) {
202
        return $this->async_restore_course($backupid, 0, $userid, 0);
202
        return $this->async_restore_course($backupid, 0, $userid, 0);
203
    }
203
    }
Línea 204... Línea 204...
204
 
204
 
205
    public function test_async_restore_existing_idnumber_in_new_course() {
205
    public function test_async_restore_existing_idnumber_in_new_course(): void {
Línea 206... Línea 206...
206
        $this->resetAfterTest();
206
        $this->resetAfterTest();
207
 
207
 
208
        $dg = $this->getDataGenerator();
208
        $dg = $this->getDataGenerator();
Línea 212... Línea 212...
212
 
212
 
213
        // The ID number is set empty.
213
        // The ID number is set empty.
214
        $this->assertEquals('', $c2->idnumber);
214
        $this->assertEquals('', $c2->idnumber);
Línea 215... Línea 215...
215
    }
215
    }
216
 
216
 
217
    public function test_async_restore_course_info_in_existing_course() {
217
    public function test_async_restore_course_info_in_existing_course(): void {
218
        global $DB;
218
        global $DB;
Línea 219... Línea 219...
219
        $this->resetAfterTest();
219
        $this->resetAfterTest();
Línea 248... Línea 248...
248
        $restoredchat2 = $DB->get_record('chat', ['name' => 'Second', 'course' => $c2->id]);
248
        $restoredchat2 = $DB->get_record('chat', ['name' => 'Second', 'course' => $c2->id]);
249
        $this->assertEquals($chat1->chattime, $restoredchat1->chattime);
249
        $this->assertEquals($chat1->chattime, $restoredchat1->chattime);
250
        $this->assertEquals($chat2->chattime, $restoredchat2->chattime);
250
        $this->assertEquals($chat2->chattime, $restoredchat2->chattime);
251
    }
251
    }
Línea 252... Línea 252...
252
 
252
 
253
    public function test_async_restore_course_info_in_existing_course_delete_first() {
253
    public function test_async_restore_course_info_in_existing_course_delete_first(): void {
254
        global $DB;
254
        global $DB;
255
        $this->resetAfterTest();
255
        $this->resetAfterTest();
Línea 256... Línea 256...
256
        $dg = $this->getDataGenerator();
256
        $dg = $this->getDataGenerator();
Línea 279... Línea 279...
279
        $restoredchat2 = $DB->get_record('chat', ['name' => 'Second', 'course' => $c2->id]);
279
        $restoredchat2 = $DB->get_record('chat', ['name' => 'Second', 'course' => $c2->id]);
280
        $this->assertEquals($chat1->chattime, $restoredchat1->chattime);
280
        $this->assertEquals($chat1->chattime, $restoredchat1->chattime);
281
        $this->assertEmpty($restoredchat2);
281
        $this->assertEmpty($restoredchat2);
282
    }
282
    }
Línea 283... Línea 283...
283
 
283
 
284
    public function test_restore_existing_idnumber_in_new_course() {
284
    public function test_restore_existing_idnumber_in_new_course(): void {
Línea 285... Línea 285...
285
        $this->resetAfterTest();
285
        $this->resetAfterTest();
286
 
286
 
287
        $dg = $this->getDataGenerator();
287
        $dg = $this->getDataGenerator();
Línea 291... Línea 291...
291
 
291
 
292
        // The ID number is set empty.
292
        // The ID number is set empty.
293
        $this->assertEquals('', $c2->idnumber);
293
        $this->assertEquals('', $c2->idnumber);
Línea 294... Línea 294...
294
    }
294
    }
295
 
295
 
296
    public function test_restore_non_existing_idnumber_in_new_course() {
296
    public function test_restore_non_existing_idnumber_in_new_course(): void {
Línea 297... Línea 297...
297
        global $DB;
297
        global $DB;
298
        $this->resetAfterTest();
298
        $this->resetAfterTest();
Línea 307... Línea 307...
307
        // The ID number changed.
307
        // The ID number changed.
308
        $c2 = $this->restore_to_new_course($backupid);
308
        $c2 = $this->restore_to_new_course($backupid);
309
        $this->assertEquals('ABC', $c2->idnumber);
309
        $this->assertEquals('ABC', $c2->idnumber);
310
    }
310
    }
Línea 311... Línea 311...
311
 
311
 
312
    public function test_restore_existing_idnumber_in_existing_course() {
312
    public function test_restore_existing_idnumber_in_existing_course(): void {
313
        global $DB;
313
        global $DB;
Línea 314... Línea 314...
314
        $this->resetAfterTest();
314
        $this->resetAfterTest();
315
 
315
 
Línea 324... Línea 324...
324
 
324
 
325
        $c1 = $DB->get_record('course', array('id' => $c1->id));
325
        $c1 = $DB->get_record('course', array('id' => $c1->id));
326
        $this->assertEquals('ABC', $c1->idnumber);
326
        $this->assertEquals('ABC', $c1->idnumber);
Línea 327... Línea 327...
327
    }
327
    }
328
 
328
 
329
    public function test_restore_non_existing_idnumber_in_existing_course() {
329
    public function test_restore_non_existing_idnumber_in_existing_course(): void {
Línea 330... Línea 330...
330
        global $DB;
330
        global $DB;
331
        $this->resetAfterTest();
331
        $this->resetAfterTest();
Línea 341... Línea 341...
341
        // The ID number has changed.
341
        // The ID number has changed.
342
        $c2 = $this->restore_to_existing_course($backupid, $c2->id);
342
        $c2 = $this->restore_to_existing_course($backupid, $c2->id);
343
        $this->assertEquals('ABC', $c2->idnumber);
343
        $this->assertEquals('ABC', $c2->idnumber);
344
    }
344
    }
Línea 345... Línea 345...
345
 
345
 
346
    public function test_restore_idnumber_in_existing_course_without_permissions() {
346
    public function test_restore_idnumber_in_existing_course_without_permissions(): void {
347
        global $DB;
347
        global $DB;
348
        $this->resetAfterTest();
348
        $this->resetAfterTest();
349
        $dg = $this->getDataGenerator();
349
        $dg = $this->getDataGenerator();
Línea 365... Línea 365...
365
        // The ID number does not change.
365
        // The ID number does not change.
366
        $c2 = $this->restore_to_existing_course($backupid, $c2->id, $u1->id);
366
        $c2 = $this->restore_to_existing_course($backupid, $c2->id, $u1->id);
367
        $this->assertEquals('DEF', $c2->idnumber);
367
        $this->assertEquals('DEF', $c2->idnumber);
368
    }
368
    }
Línea 369... Línea 369...
369
 
369
 
370
    public function test_restore_course_info_in_new_course() {
370
    public function test_restore_course_info_in_new_course(): void {
371
        global $DB;
371
        global $DB;
372
        $this->resetAfterTest();
372
        $this->resetAfterTest();
Línea 373... Línea 373...
373
        $dg = $this->getDataGenerator();
373
        $dg = $this->getDataGenerator();
Línea 385... Línea 385...
385
        $this->assertEquals('DESC', $c2->summary);
385
        $this->assertEquals('DESC', $c2->summary);
386
        $this->assertEquals(FORMAT_MOODLE, $c2->summaryformat);
386
        $this->assertEquals(FORMAT_MOODLE, $c2->summaryformat);
387
        $this->assertEquals($startdate, $c2->startdate);
387
        $this->assertEquals($startdate, $c2->startdate);
388
    }
388
    }
Línea 389... Línea 389...
389
 
389
 
390
    public function test_restore_course_with_users() {
390
    public function test_restore_course_with_users(): void {
391
        global $DB;
391
        global $DB;
392
        $this->resetAfterTest();
392
        $this->resetAfterTest();
393
        $this->setAdminUser();
393
        $this->setAdminUser();
Línea 421... Línea 421...
421
        $this->assertEquals($c2->id, $events[0]->other['courseid']);
421
        $this->assertEquals($c2->id, $events[0]->other['courseid']);
422
        $this->assertStringContainsString("during restore of the course with id '{$c2->id}'",
422
        $this->assertStringContainsString("during restore of the course with id '{$c2->id}'",
423
            $events[0]->get_description());
423
            $events[0]->get_description());
424
    }
424
    }
Línea 425... Línea 425...
425
 
425
 
426
    public function test_restore_course_info_in_existing_course() {
426
    public function test_restore_course_info_in_existing_course(): void {
427
        global $DB;
427
        global $DB;
428
        $this->resetAfterTest();
428
        $this->resetAfterTest();
Línea 429... Línea 429...
429
        $dg = $this->getDataGenerator();
429
        $dg = $this->getDataGenerator();
Línea 457... Línea 457...
457
        $restoredchat2 = $DB->get_record('chat', ['name' => 'Second', 'course' => $c2->id]);
457
        $restoredchat2 = $DB->get_record('chat', ['name' => 'Second', 'course' => $c2->id]);
458
        $this->assertEquals($chat1->chattime, $restoredchat1->chattime);
458
        $this->assertEquals($chat1->chattime, $restoredchat1->chattime);
459
        $this->assertEquals($chat2->chattime, $restoredchat2->chattime);
459
        $this->assertEquals($chat2->chattime, $restoredchat2->chattime);
460
    }
460
    }
Línea 461... Línea 461...
461
 
461
 
462
    public function test_restore_course_shortname_in_existing_course_without_permissions() {
462
    public function test_restore_course_shortname_in_existing_course_without_permissions(): void {
463
        global $DB;
463
        global $DB;
464
        $this->resetAfterTest();
464
        $this->resetAfterTest();
465
        $dg = $this->getDataGenerator();
465
        $dg = $this->getDataGenerator();
Línea 481... Línea 481...
481
        $this->assertEquals('FN copy 1', $restored->fullname);
481
        $this->assertEquals('FN copy 1', $restored->fullname);
482
        $this->assertEquals('DESC', $restored->summary);
482
        $this->assertEquals('DESC', $restored->summary);
483
        $this->assertEquals(FORMAT_MOODLE, $restored->summaryformat);
483
        $this->assertEquals(FORMAT_MOODLE, $restored->summaryformat);
484
    }
484
    }
Línea 485... Línea 485...
485
 
485
 
486
    public function test_restore_course_fullname_in_existing_course_without_permissions() {
486
    public function test_restore_course_fullname_in_existing_course_without_permissions(): void {
487
        global $DB;
487
        global $DB;
488
        $this->resetAfterTest();
488
        $this->resetAfterTest();
489
        $dg = $this->getDataGenerator();
489
        $dg = $this->getDataGenerator();
Línea 505... Línea 505...
505
        $this->assertEquals($c2->fullname, $restored->fullname);
505
        $this->assertEquals($c2->fullname, $restored->fullname);
506
        $this->assertEquals('DESC', $restored->summary);
506
        $this->assertEquals('DESC', $restored->summary);
507
        $this->assertEquals(FORMAT_MOODLE, $restored->summaryformat);
507
        $this->assertEquals(FORMAT_MOODLE, $restored->summaryformat);
508
    }
508
    }
Línea 509... Línea 509...
509
 
509
 
510
    public function test_restore_course_summary_in_existing_course_without_permissions() {
510
    public function test_restore_course_summary_in_existing_course_without_permissions(): void {
511
        global $DB;
511
        global $DB;
512
        $this->resetAfterTest();
512
        $this->resetAfterTest();
513
        $dg = $this->getDataGenerator();
513
        $dg = $this->getDataGenerator();
Línea 529... Línea 529...
529
        $this->assertEquals('FN copy 1', $restored->fullname);
529
        $this->assertEquals('FN copy 1', $restored->fullname);
530
        $this->assertEquals($c2->summary, $restored->summary);
530
        $this->assertEquals($c2->summary, $restored->summary);
531
        $this->assertEquals($c2->summaryformat, $restored->summaryformat);
531
        $this->assertEquals($c2->summaryformat, $restored->summaryformat);
532
    }
532
    }
Línea 533... Línea 533...
533
 
533
 
534
    public function test_restore_course_startdate_in_existing_course_without_permissions() {
534
    public function test_restore_course_startdate_in_existing_course_without_permissions(): void {
535
        global $DB;
535
        global $DB;
536
        $this->resetAfterTest();
536
        $this->resetAfterTest();
Línea 537... Línea 537...
537
        $dg = $this->getDataGenerator();
537
        $dg = $this->getDataGenerator();
Línea 575... Línea 575...
575
     * Tests course restore with editor in course format.
575
     * Tests course restore with editor in course format.
576
     *
576
     *
577
     * @author Matthew Hilton
577
     * @author Matthew Hilton
578
     * @covers \core_courseformat
578
     * @covers \core_courseformat
579
     */
579
     */
580
    public function test_restore_editor_courseformat() {
580
    public function test_restore_editor_courseformat(): void {
581
        $this->resetAfterTest();
581
        $this->resetAfterTest();
Línea 582... Línea 582...
582
 
582
 
583
        // Setup user with restore permissions.
583
        // Setup user with restore permissions.
584
        $dg = $this->getDataGenerator();
584
        $dg = $this->getDataGenerator();