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.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]

Unit tests for backups cron helper.

Copyright: 2012 Frédéric Massart <fred@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 510 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

backup_cron_helper_testcase:: (6 methods):
  test_next_automated_backup()
  test_get_backups_to_delete()
  test_is_course_modified()
  course_setup()
  test_get_courses()
  test_get_courses_starttime()

testable_backup_cron_automated_helper:: (3 methods):
  testable_get_backups_to_delete()
  testable_is_course_modified()
  testable_get_courses()


Class: backup_cron_helper_testcase  - X-Ref

Unit tests for backup cron helper

test_next_automated_backup()   X-Ref
Test {@link backup_cron_automated_helper::calculate_next_automated_backup}.


test_get_backups_to_delete()   X-Ref
Test {@link backup_cron_automated_helper::get_backups_to_delete}.


test_is_course_modified()   X-Ref
Test {@link backup_cron_automated_helper::is_course_modified}.


course_setup()   X-Ref
Create courses and backup records for tests.

return: array Created courses.

test_get_courses()   X-Ref
Test the selection and ordering of courses to be backed up.


test_get_courses_starttime()   X-Ref
Test the selection and ordering of courses to be backed up.
Where it is not yet time to start backups for courses with existing backups.


Class: testable_backup_cron_automated_helper  - X-Ref

Provides access to protected methods we want to explicitly test

testable_get_backups_to_delete($backupfiles, $now)   X-Ref
Provides access to protected method get_backups_to_remove.

param: array $backupfiles Existing backup files
param: int $now Starting time of the process
return: array Backup files to remove

testable_is_course_modified($courseid, $since)   X-Ref
Provides access to protected method get_backups_to_remove.

param: int $courseid course id to check
param: int $since timestamp, from which to check
return: bool true if the course was modified, false otherwise. This also returns false if no readers are enabled. This is

testable_get_courses($now)   X-Ref
Provides access to protected method get_courses.

param: int $now Timestamp to use.
return: moodle_recordset The returned courses as a Moodle recordest.