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 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