Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

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.