diff --git a/backup/controller/tests/controller_test.php b/backup/controller/tests/controller_test.php index d5142f153762a..c34ff288cac89 100644 --- a/backup/controller/tests/controller_test.php +++ b/backup/controller/tests/controller_test.php @@ -149,6 +149,32 @@ public function test_restore_controller_is_executing() { } $this->assertTrue($alltrue); } + + /** + * Test restore of deadlock causing backup. + */ + public function test_restore_of_deadlock_causing_backup() { + global $USER, $CFG; + $this->preventResetByRollback(); + + $foldername = 'deadlock'; + $fp = get_file_packer('application/vnd.moodle.backup'); + $tempdir = $CFG->dataroot . '/temp/backup/' . $foldername; + $files = $fp->extract_to_pathname($CFG->dirroot . '/backup/controller/tests/fixtures/deadlock.mbz', $tempdir); + + $this->setAdminUser(); + $controller = new restore_controller( + 'deadlock', + $this->courseid, + backup::INTERACTIVE_NO, + backup::MODE_GENERAL, + $USER->id, + backup::TARGET_NEW_COURSE + ); + $this->assertTrue($controller->execute_precheck()); + $controller->execute_plan(); + $controller->destroy(); + } } diff --git a/backup/controller/tests/fixtures/deadlock.mbz b/backup/controller/tests/fixtures/deadlock.mbz new file mode 100644 index 0000000000000..f45a956a161f1 Binary files /dev/null and b/backup/controller/tests/fixtures/deadlock.mbz differ