Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 39 and 402]

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: 520 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

cronhelper_test:: (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: cronhelper_test  - X-Ref

Unit tests for backups 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.