Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

Unit tests for MoodleQuickForm_duration Contains test cases for testing MoodleQuickForm_duration

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

Defines 2 classes


Class: duration_test  - 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