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]

Choice module library functions tests

Copyright: 2015 Juan Leyva <juan@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1358 lines (55 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

lib_test:: (33 methods):
  test_choice_view()
  test_choice_can_view_results()
  test_choice_user_submit_response_validation()
  test_choice_get_user_response()
  test_choice_get_my_response()
  test_choice_get_availability_status()
  test_choice_core_calendar_provide_event_action_in_hidden_section()
  test_choice_core_calendar_provide_event_action_for_non_user()
  test_choice_core_calendar_provide_event_action_open()
  test_choice_core_calendar_provide_event_action_open_for_user()
  test_choice_core_calendar_provide_event_action_already_submitted()
  test_choice_core_calendar_provide_event_action_already_submitted_for_user()
  test_choice_core_calendar_provide_event_action_closed()
  test_choice_core_calendar_provide_event_action_closed_for_user()
  test_choice_core_calendar_provide_event_action_open_in_future()
  test_choice_core_calendar_provide_event_action_open_in_future_for_user()
  test_choice_core_calendar_provide_event_action_no_time_specified()
  test_choice_core_calendar_provide_event_action_no_time_specified_for_user()
  test_choice_core_calendar_provide_event_action_already_completed()
  test_choice_core_calendar_provide_event_action_already_completed_for_user()
  create_action_event()
  test_mod_choice_completion_get_active_rule_descriptions()
  test_mod_choice_core_calendar_event_timestart_updated_unknown_event()
  test_mod_choice_core_calendar_event_timestart_updated_open_event()
  test_mod_choice_core_calendar_event_timestart_updated_close_event()
  test_mod_choice_core_calendar_get_valid_event_timestart_range_unknown_event()
  test_mod_choice_core_calendar_get_valid_event_timestart_range_open_event()
  test_mod_choice_core_calendar_get_valid_event_timestart_range_close_event()
  test_choice_user_submit_response_no_multiple_no_limits()
  test_choice_user_submit_response_multiples_no_limits()
  test_choice_user_submit_response_no_multiples_limits()
  test_choice_user_submit_response_multiples_limits()
  test_creation_with_no_calendar_capabilities()


Class: lib_test  - X-Ref

Choice module library functions tests

test_choice_view()   X-Ref
Test choice_view

return: void

test_choice_can_view_results()   X-Ref
Test choice_can_view_results

return: void

test_choice_user_submit_response_validation()   X-Ref
No description

test_choice_get_user_response()   X-Ref
Test choice_get_user_response

return: void

test_choice_get_my_response()   X-Ref
Test choice_get_my_response

return: void

test_choice_get_availability_status()   X-Ref
Test choice_get_availability_status

return: void

test_choice_core_calendar_provide_event_action_in_hidden_section()   X-Ref
No description

test_choice_core_calendar_provide_event_action_for_non_user()   X-Ref
No description

test_choice_core_calendar_provide_event_action_open()   X-Ref
No description

test_choice_core_calendar_provide_event_action_open_for_user()   X-Ref
No description

test_choice_core_calendar_provide_event_action_already_submitted()   X-Ref
An event should not have an action if the user has already submitted a response
to the choice activity.


test_choice_core_calendar_provide_event_action_already_submitted_for_user()   X-Ref
An event should not have an action if the user has already submitted a response
to the choice activity.


test_choice_core_calendar_provide_event_action_closed()   X-Ref
No description

test_choice_core_calendar_provide_event_action_closed_for_user()   X-Ref
No description

test_choice_core_calendar_provide_event_action_open_in_future()   X-Ref
No description

test_choice_core_calendar_provide_event_action_open_in_future_for_user()   X-Ref
No description

test_choice_core_calendar_provide_event_action_no_time_specified()   X-Ref
No description

test_choice_core_calendar_provide_event_action_no_time_specified_for_user()   X-Ref
No description

test_choice_core_calendar_provide_event_action_already_completed()   X-Ref
No description

test_choice_core_calendar_provide_event_action_already_completed_for_user()   X-Ref
No description

create_action_event($courseid, $instanceid, $eventtype, $timestart = null)   X-Ref
Creates an action event.

param: int $courseid
param: int $instanceid The choice id.
param: string $eventtype The event type. eg. CHOICE_EVENT_TYPE_OPEN.
param: int|null $timestart The start timestamp for the event
return: bool|calendar_event

test_mod_choice_completion_get_active_rule_descriptions()   X-Ref
Test the callback responsible for returning the completion rule descriptions.
This function should work given either an instance of the module (cm_info), such as when checking the active rules,
or if passed a stdClass of similar structure, such as when checking the the default completion settings for a mod type.


test_mod_choice_core_calendar_event_timestart_updated_unknown_event()   X-Ref
An unkown event type should not change the choice instance.


test_mod_choice_core_calendar_event_timestart_updated_open_event()   X-Ref
A CHOICE_EVENT_TYPE_OPEN event should update the timeopen property of
the choice activity.


test_mod_choice_core_calendar_event_timestart_updated_close_event()   X-Ref
A CHOICE_EVENT_TYPE_CLOSE event should update the timeclose property of
the choice activity.


test_mod_choice_core_calendar_get_valid_event_timestart_range_unknown_event()   X-Ref
An unkown event type should not have any limits


test_mod_choice_core_calendar_get_valid_event_timestart_range_open_event()   X-Ref
The open event should be limited by the choice's timeclose property, if it's set.


test_mod_choice_core_calendar_get_valid_event_timestart_range_close_event()   X-Ref
The close event should be limited by the choice's timeopen property, if it's set.


test_choice_user_submit_response_no_multiple_no_limits()   X-Ref
Test choice_user_submit_response for a choice with specific options.
Options:
allowmultiple: false
limitanswers: false


test_choice_user_submit_response_multiples_no_limits()   X-Ref
Test choice_user_submit_response for a choice with specific options.
Options:
allowmultiple: true
limitanswers: false


test_choice_user_submit_response_no_multiples_limits()   X-Ref
Test choice_user_submit_response for a choice with specific options.
Options:
allowmultiple: false
limitanswers: true


test_choice_user_submit_response_multiples_limits()   X-Ref
Test choice_user_submit_response for a choice with specific options.
Options:
allowmultiple: true
limitanswers: true


test_creation_with_no_calendar_capabilities()   X-Ref
A user who does not have capabilities to add events to the calendar should be able to create an choice.