Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Class: core_backup_moodle2_testcase  - X-Ref

Tests for Moodle 2 format backup operation.

test_backup_availability()   X-Ref
Tests the availability field on modules and sections is correctly
backed up and restored.


test_restore_legacy_availability()   X-Ref
The availability data format was changed in Moodle 2.7. This test
ensures that a Moodle 2.6 backup with this data can still be correctly
restored.


test_duplicate_availability()   X-Ref
Tests the backup and restore of single activity to same course (duplicate)
when it contains availability conditions that depend on other items in
course.


test_restore_dates()   X-Ref
When restoring a course, you can change the start date, which shifts other
dates. This test checks that certain dates are correctly modified.


test_restore_frontpage()   X-Ref
Test front page backup/restore and duplicate activities

return: void

backup_and_restore($course, $newdate = 0, $inbetween = null)   X-Ref
Backs a course up and restores it.

param: stdClass $course Course object to backup
param: int $newdate If non-zero, specifies custom date for new course
param: callable|null $inbetween If specified, function that is called before restore
return: int ID of newly restored course

duplicate($course, $cmid)   X-Ref
Duplicates a single activity within a course.

This is based on the code from course/modduplicate.php, but reduced for
simplicity.

param: stdClass $course Course object
param: int $cmid Activity to duplicate
return: int ID of new activity

prepare_for_enrolments_test($target, $additionalcaps = [])   X-Ref
Help function for enrolment methods backup/restore tests:

- Creates a course ($course), adds self-enrolment method and a user
- Makes a backup
- Creates a target course (if requested) ($newcourseid)
- Initialises restore controller for this backup file ($rc)

param: int $target target for restoring: backup::TARGET_NEW_COURSE etc.
param: array $additionalcaps - additional capabilities to give to user
return: array array of original course, new course id, restore controller: [$course, $newcourseid, $rc]

test_restore_without_users_without_enrolments()   X-Ref
Backup a course with enrolment methods and restore it without user data and without enrolment methods


test_restore_without_users_with_enrolments()   X-Ref
Backup a course with enrolment methods and restore it without user data with enrolment methods


test_restore_with_users_without_enrolments()   X-Ref
Backup a course with enrolment methods and restore it with user data and without enrolment methods


test_restore_with_users_with_enrolments()   X-Ref
Backup a course with enrolment methods and restore it with user data with enrolment methods


test_restore_with_users_with_enrolments_merging()   X-Ref
Backup a course with enrolment methods and restore it with user data with enrolment methods merging into another course


test_restore_with_users_with_enrolments_deleting()   X-Ref
Backup a course with enrolment methods and restore it with user data with enrolment methods into another course deleting it's contents


test_block_instance_times_backup()   X-Ref
Test the block instance time fields (timecreated, timemodified) through a backup and restore.


test_restore_search_index_requests()   X-Ref
When you restore a site with global search (or search indexing) turned on, then it should
add entries to the search index requests table so that the data gets indexed.


test_restore_course_using_plan_defaults()   X-Ref
Test restoring courses based on the backup plan. Primarily used with
the import functionality


test_restore_question_category_34_35()   X-Ref
The Question category hierarchical structure was changed in Moodle 3.5.
From 3.5, all question categories in each context are a child of a single top level question category for that context.
This test ensures that both Moodle 3.4 and 3.5 backups can still be correctly restored.


test_contentbank_content_backup()   X-Ref
Test the content bank content through a backup and restore.