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]

This file contains the class that handles testing the calendar type system.

Copyright: 2013 Mark Nelson <markn@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 331 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes


Class: calendartype_test  - X-Ref

Unit tests for the calendar type system.

setUp()   X-Ref
Test set up.


test_calendar_type_set()   X-Ref
Test that setting the calendar type works.


test_calendar_type_core_functions()   X-Ref
Test that calling core Moodle functions responsible for displaying the date
have the same results as directly calling the same function in the calendar type.


test_calendar_type_dateselector_elements()   X-Ref
Test that dates selected using the date selector elements are being saved as unixtime, and that the
unixtime is being converted back to a valid date to display in the date selector elements for
different calendar types.


test_calendar_type_datetime_field_submission()   X-Ref
Test that the user profile field datetime minimum and maximum year settings are saved as the
equivalent Gregorian years.


core_functions_test($type)   X-Ref
Test all the core functions that use the calendar type system.

param: string $type the calendar type we want to test

convert_dateselector_to_unixtime_test($element, $type, $date)   X-Ref
Simulates submitting a form with a date selector element and tests that the chosen dates
are converted into unixtime before being saved in DB.

param: string $element the form element we are testing
param: string $type the calendar type we want to test
param: array $date the date variables

convert_unixtime_to_dateselector_test($type, $date)   X-Ref
Test converting dates from unixtime to a date for the calendar type specified.

param: string $type the calendar type we want to test
param: array $date the date variables

datetime_field_submission_test($type, $date)   X-Ref
Test saving the minimum and max year settings for the user datetime field.

param: string $type the calendar type we want to test
param: array $date the date variables

set_calendar_type($type)   X-Ref
Set the calendar type for this user.

param: string $type the calendar type we want to set

Class: temp_form_calendartype  - X-Ref

Form object to be used in test case.

definition()   X-Ref
Form definition.


getform()   X-Ref
Returns form reference

return: MoodleQuickForm