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]

Unit tests for (some of) mod/feedback/lib.php.

Copyright: 2016 Stephen Bourget
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1166 lines (49 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

lib_test:: (30 methods):
  test_feedback_initialise()
  test_feedback_refresh_events()
  test_check_updates_since()
  test_feedback_core_calendar_provide_event_action_open()
  test_feedback_core_calendar_provide_event_action_open_for_user()
  test_feedback_core_calendar_provide_event_action_closed()
  test_feedback_core_calendar_provide_event_action_closed_for_user()
  test_feedback_core_calendar_provide_event_action_open_in_future()
  test_feedback_core_calendar_provide_event_action_open_in_future_for_user()
  test_feedback_core_calendar_provide_event_action_no_time_specified()
  test_feedback_core_calendar_provide_event_action_no_time_specified_for_user()
  test_feedback_core_calendar_provide_event_action_can_not_submit()
  test_feedback_core_calendar_provide_event_action_can_not_submit_for_user()
  test_feedback_core_calendar_provide_event_action_already_submitted()
  test_feedback_core_calendar_provide_event_action_already_submitted_for_user()
  test_feedback_core_calendar_provide_event_action_already_completed()
  test_feedback_core_calendar_provide_event_action_already_completed_for_user()
  create_action_event()
  test_mod_feedback_completion_get_active_rule_descriptions()
  test_get_valid_event_timestart_range_unknown_event()
  test_get_valid_event_timestart_range_event_type_open()
  test_get_valid_event_timestart_range_event_type_open_no_close()
  test_get_valid_event_timestart_range_event_type_close()
  test_get_valid_event_timestart_range_event_type_close_no_open()
  test_mod_feedback_core_calendar_event_timestart_updated_unknown_event()
  test_mod_feedback_core_calendar_event_timestart_updated_open_event()
  test_mod_feedback_core_calendar_event_timestart_updated_close_event()
  test_student_role_cant_update_time_close_event()
  test_teacher_role_can_update_time_close_event()
  test_creation_with_no_calendar_capabilities()


Class: lib_test  - X-Ref

Unit tests for (some of) mod/feedback/lib.php.

test_feedback_initialise()   X-Ref
No description

test_feedback_refresh_events()   X-Ref
Tests for mod_feedback_refresh_events.


test_check_updates_since()   X-Ref
Test check_updates_since callback.


test_feedback_core_calendar_provide_event_action_open()   X-Ref
Test calendar event provide action open.


test_feedback_core_calendar_provide_event_action_open_for_user()   X-Ref
Test calendar event provide action open, viewed by a different user.


test_feedback_core_calendar_provide_event_action_closed()   X-Ref
Test calendar event provide action closed.


test_feedback_core_calendar_provide_event_action_closed_for_user()   X-Ref
Test calendar event provide action closed, viewed by a different user.


test_feedback_core_calendar_provide_event_action_open_in_future()   X-Ref
Test calendar event action open in future.


test_feedback_core_calendar_provide_event_action_open_in_future_for_user()   X-Ref
Test calendar event action open in future, viewed by a different user.


test_feedback_core_calendar_provide_event_action_no_time_specified()   X-Ref
Test calendar event with no time specified.


test_feedback_core_calendar_provide_event_action_no_time_specified_for_user()   X-Ref
Test calendar event with no time specified, viewed by a different user.


test_feedback_core_calendar_provide_event_action_can_not_submit()   X-Ref
A user that can not submit feedback should not have an action.


test_feedback_core_calendar_provide_event_action_can_not_submit_for_user()   X-Ref
A user that can not submit feedback should not have an action, viewed by a different user.


test_feedback_core_calendar_provide_event_action_already_submitted()   X-Ref
A user that has already submitted feedback should not have an action.


test_feedback_core_calendar_provide_event_action_already_submitted_for_user()   X-Ref
A user that has already submitted feedback should not have an action, viewed by a different user.


test_feedback_core_calendar_provide_event_action_already_completed()   X-Ref
No description

test_feedback_core_calendar_provide_event_action_already_completed_for_user()   X-Ref
No description

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

param: int $courseid The course id.
param: int $instanceid The feedback id.
param: string $eventtype The event type. eg. FEEDBACK_EVENT_TYPE_OPEN.
return: bool|calendar_event

test_mod_feedback_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_get_valid_event_timestart_range_unknown_event()   X-Ref
An unknown event should not have min or max restrictions.


test_get_valid_event_timestart_range_event_type_open()   X-Ref
A FEEDBACK_EVENT_TYPE_OPEN should have a max timestart equal to the activity
close time.


test_get_valid_event_timestart_range_event_type_open_no_close()   X-Ref
A FEEDBACK_EVENT_TYPE_OPEN should not have a max timestamp if the activity
doesn't have a close date.


test_get_valid_event_timestart_range_event_type_close()   X-Ref
A FEEDBACK_EVENT_TYPE_CLOSE should have a min timestart equal to the activity
open time.


test_get_valid_event_timestart_range_event_type_close_no_open()   X-Ref
A FEEDBACK_EVENT_TYPE_CLOSE should not have a minimum timestamp if the activity
doesn't have an open date.


test_mod_feedback_core_calendar_event_timestart_updated_unknown_event()   X-Ref
An unkown event type should not change the feedback instance.


test_mod_feedback_core_calendar_event_timestart_updated_open_event()   X-Ref
A FEEDBACK_EVENT_TYPE_OPEN event should update the timeopen property of
the feedback activity.


test_mod_feedback_core_calendar_event_timestart_updated_close_event()   X-Ref
A FEEDBACK_EVENT_TYPE_CLOSE event should update the timeclose property of
the feedback activity.


test_student_role_cant_update_time_close_event()   X-Ref
If a student somehow finds a way to update the calendar event
then the callback should not be executed to update the activity
properties as well because that would be a security issue.


test_teacher_role_can_update_time_close_event()   X-Ref
The activity should update if a teacher modifies the calendar
event.


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