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 forms lib. This file contains all unit test related to forms library.

Copyright: 2009 Tim Hunt
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 213 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes


Class: core_form_duration_testcase  - X-Ref

Unit tests for MoodleQuickForm_duration

Contains test cases for testing MoodleQuickForm_duration

get_test_form()   X-Ref
Get a form that can be used for testing.

return: MoodleQuickForm

get_test_form_and_element()   X-Ref
Get a form with a duration element that can be used for testing.

return: array with two elements, a MoodleQuickForm and a MoodleQuickForm_duration.

test_constructor_rejects_invalid_unit()   X-Ref
Test the constructor error handling.


test_constructor_limited_units()   X-Ref
Test constructor only some units.


test_get_units()   X-Ref
Testcase for testing units (seconds, minutes, hours and days)


seconds_to_unit_cases()   X-Ref
Data provider for {@see test_seconds_to_unit()}.

return: array test cases.

test_seconds_to_unit(array $expected, int $seconds)   X-Ref
Testcase for testing conversion of seconds to the best possible unit.

param: array $expected expected return value from seconds_to_unit
param: int $seconds value to pass to seconds_to_unit

test_seconds_to_unit_different_default_unit()   X-Ref
Testcase for testing conversion of seconds to the best possible unit with a non-default default unit.


export_value_cases()   X-Ref
Data provider for {@see test_export_value()}.

return: array test cases.

test_export_value(int $expected, string $number, int $unit, int $enabled = 0,bool $optional = false, ?string $label = null)   X-Ref
Testcase to check generated timestamp

param: int $expected Expected value returned by the element.
param: string $number Number entered into the element.
param: int $unit Unit selected in the element.
param: int $enabled Whether the enabled checkbox on the form was selected. (Only used if $optional is true.)
param: bool $optional Whether the element has the optional option on.
param: string|null $label The element's label.

Class: temp_form_duration  - X-Ref

Form object to be used in test case.

definition()   X-Ref
Form definition.


getform()   X-Ref
Returns form reference

return: MoodleQuickForm