MDL-64843 Backup: Course copy user interface
This patch adds better core support for copying courses. There is now a simplified and dedicated UI for copying courses. This can be accessed from the course context menu or course management screens. All backups are done asynchronously and there can be multiple copies of a course in flight at once.
This commit is contained in:
@@ -60,6 +60,20 @@ class core_backup_controller_testcase extends advanced_testcase {
|
||||
$CFG->backup_file_logger_level_extra = backup::LOG_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set copy method.
|
||||
*/
|
||||
public function test_base_controller_set_copy() {
|
||||
$this->expectException(\backup_controller_exception::class);
|
||||
$copy = new \stdClass();
|
||||
|
||||
// Set up controller as a non-copy operation.
|
||||
$bc = new \backup_controller(backup::TYPE_1COURSE, $this->courseid, backup::FORMAT_MOODLE,
|
||||
backup::INTERACTIVE_NO, backup::MODE_GENERAL, $this->userid, backup::RELEASESESSION_YES);
|
||||
|
||||
$bc->set_copy($copy);
|
||||
}
|
||||
|
||||
/*
|
||||
* test base_setting class
|
||||
*/
|
||||
@@ -103,6 +117,19 @@ class core_backup_controller_testcase extends advanced_testcase {
|
||||
$this->assertEquals($bc->get_include_files(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set kept roles method.
|
||||
*/
|
||||
public function test_backup_controller_set_kept_roles() {
|
||||
$this->expectException(\backup_controller_exception::class);
|
||||
|
||||
// Set up controller as a non-copy operation.
|
||||
$bc = new \backup_controller(backup::TYPE_1COURSE, $this->courseid, backup::FORMAT_MOODLE,
|
||||
backup::INTERACTIVE_NO, backup::MODE_GENERAL, $this->userid, backup::RELEASESESSION_YES);
|
||||
|
||||
$bc->set_kept_roles(array(1, 3, 5));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the restore_controller.
|
||||
*/
|
||||
@@ -150,6 +177,29 @@ class core_backup_controller_testcase extends advanced_testcase {
|
||||
$this->assertTrue($alltrue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test prepare copy method.
|
||||
*/
|
||||
public function test_restore_controller_prepare_copy() {
|
||||
$this->expectException(\restore_controller_exception::class);
|
||||
|
||||
global $CFG;
|
||||
|
||||
// Make a backup.
|
||||
make_backup_temp_directory('');
|
||||
$bc = new backup_controller(backup::TYPE_1ACTIVITY, $this->moduleid, backup::FORMAT_MOODLE,
|
||||
backup::INTERACTIVE_NO, backup::MODE_IMPORT, $this->userid);
|
||||
$backupid = $bc->get_backupid();
|
||||
$bc->execute_plan();
|
||||
$bc->destroy();
|
||||
|
||||
// Set up restore.
|
||||
$rc = new restore_controller($backupid, $this->courseid,
|
||||
backup::INTERACTIVE_NO, backup::MODE_SAMESITE, $this->userid,
|
||||
backup::TARGET_EXISTING_ADDING);
|
||||
$rc->prepare_copy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test restore of deadlock causing backup.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user