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 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

(no description)

File Size: 3088 lines (136 kb)
Included or required:0 times
Referenced: 2 times
Includes or requires: 0 files

Defines 1 class

externallib_test:: (56 methods):
  setUp()
  create_calendar_event()
  test_create_calendar_events()
  test_delete_calendar_events()
  test_get_calendar_events()
  test_get_calendar_events_with_mathjax()
  test_core_create_calendar_events()
  test_get_calendar_action_events_by_timesort_after_time()
  test_get_calendar_action_events_by_timesort_before_time()
  test_get_calendar_events_override()
  test_get_calendar_action_events_by_timesort_time_range()
  test_get_calendar_action_events_by_timesort_time_limit_offset()
  test_get_calendar_action_events_by_timesort_suspended_course()
  test_get_calendar_action_events_by_timesort_for_other_users()
  test_get_calendar_action_events_by_course_after_time()
  test_get_calendar_action_events_by_course_before_time()
  test_get_calendar_action_events_by_course_time_range()
  test_get_calendar_action_events_by_course_time_limit_offset()
  test_get_action_events_by_courses()
  test_delete_calendar_events_for_modules()
  test_update_event_start_day()
  test_update_event_start_day_no_permission()
  test_update_event_start_day_module_event()
  test_submit_create_update_form_validation_error()
  test_submit_create_update_form_create_user_event()
  test_submit_create_update_form_create_user_event_no_permission()
  test_submit_create_update_form_create_site_event()
  test_submit_create_update_form_create_site_event_no_permission()
  test_submit_create_update_form_create_course_event()
  test_submit_create_update_form_create_course_event_no_permission()
  test_submit_create_update_form_create_course_event_not_enrolled()
  test_submit_create_update_form_create_group_event_group_member_manage_course()
  test_submit_create_update_form_create_group_event_group_member_manage_group_entries()
  test_submit_create_update_form_create_group_event_access_all_groups()
  test_submit_create_update_form_create_group_event_non_member_no_permission()
  test_get_calendar_monthly_view_no_course_permission()
  test_get_calendar_monthly_view_with_day_provided()
  test_get_calendar_day_view_no_course_permission()
  test_get_calendar_upcoming_view_no_course_permission()
  test_get_calendar_event_by_id_no_course_permission()
  get_calendar_event_by_id_prevent_read_other_users_events_data_provider()
  test_get_calendar_event_by_id_prevent_read_other_users_events()
  edit_or_delete_other_users_events_data_provider()
  test_delete_other_users_events()
  test_edit_other_users_events()
  test_get_calendar_events_hidden_category()
  test_get_calendar_access_information_for_admins()
  test_get_calendar_access_information_for_authenticated_users()
  test_get_calendar_access_information_for_student_users()
  test_get_calendar_access_information_for_teacher_users()
  test_get_allowed_event_types_for_admins()
  test_get_allowed_event_types_for_authenticated_users()
  test_get_allowed_event_types_for_student_users()
  test_get_allowed_event_types_for_teacher_users()
  test_get_timestamps_string_keys()
  test_get_timestamps_no_keys()


Class: externallib_test  - X-Ref

External course functions unit tests

setUp()   X-Ref
Tests set up


create_calendar_event($name, $userid = 0, $type = 'user', $repeats = 0, $timestart = null, $prop = null)   X-Ref
No description

test_create_calendar_events()   X-Ref
No description

test_delete_calendar_events()   X-Ref
Test delete_calendar_events


test_get_calendar_events()   X-Ref
Test get_calendar_events


test_get_calendar_events_with_mathjax()   X-Ref
Test get_calendar_events with mathjax in the name.


test_core_create_calendar_events()   X-Ref
Test core_calendar_external::create_calendar_events


test_get_calendar_action_events_by_timesort_after_time()   X-Ref
Requesting calendar events from a given time should return all events with a sort
time at or after the requested time. All events prior to that time should not
be return.

If there are no events on or after the given time then an empty result set should
be returned.

test_get_calendar_action_events_by_timesort_before_time()   X-Ref
Requesting calendar events before a given time should return all events with a sort
time at or before the requested time (inclusive). All events after that time
should not be returned.

If there are no events before the given time then an empty result set should be
returned.

test_get_calendar_events_override()   X-Ref
Test retrieving event that was overridden for a user


test_get_calendar_action_events_by_timesort_time_range()   X-Ref
Requesting calendar events within a given time range should return all events with
a sort time between the lower and upper time bound (inclusive).

If there are no events in the given time range then an empty result set should be
returned.

test_get_calendar_action_events_by_timesort_time_limit_offset()   X-Ref
Requesting calendar events within a given time range and a limit and offset should return
the number of events up to the given limit value that have a sort time between the lower
and uppper time bound (inclusive) where the result set is shifted by the offset value.

If there are no events in the given time range then an empty result set should be
returned.

test_get_calendar_action_events_by_timesort_suspended_course()   X-Ref
Check that it is possible to restrict the calendar events to events where the user is not suspended in the course.


test_get_calendar_action_events_by_timesort_for_other_users()   X-Ref
Check that it is possible to get other user's events without the permission.


test_get_calendar_action_events_by_course_after_time()   X-Ref
Requesting calendar events from a given course and time should return all
events with a sort time at or after the requested time. All events prior
to that time should not be return.

If there are no events on or after the given time then an empty result set should
be returned.

test_get_calendar_action_events_by_course_before_time()   X-Ref
Requesting calendar events for a course and before a given time should return
all events with a sort time at or before the requested time (inclusive). All
events after that time should not be returned.

If there are no events before the given time then an empty result set should be
returned.

test_get_calendar_action_events_by_course_time_range()   X-Ref
Requesting calendar events for a course and within a given time range should
return all events with a sort time between the lower and upper time bound
(inclusive).

If there are no events in the given time range then an empty result set should be
returned.

test_get_calendar_action_events_by_course_time_limit_offset()   X-Ref
Requesting calendar events for a course and within a given time range and a limit
and offset should return the number of events up to the given limit value that have
a sort time between the lower and uppper time bound (inclusive) where the result
set is shifted by the offset value.

If there are no events in the given time range then an empty result set should be
returned.

test_get_action_events_by_courses()   X-Ref
Test that get_action_events_by_courses will return a list of events for each
course you provided as long as the user is enrolled in the course.


test_delete_calendar_events_for_modules()   X-Ref
Test for deleting module events.


test_update_event_start_day()   X-Ref
Updating the event start day should change the date value but leave
the time of day unchanged.


test_update_event_start_day_no_permission()   X-Ref
A user should not be able to edit an event that they don't have
capabilities for.


test_update_event_start_day_module_event()   X-Ref
A user should not be able to update a module event.


test_submit_create_update_form_validation_error()   X-Ref
Submit a request where the time duration until is earlier than the time
start in order to get a validation error from the server.


test_submit_create_update_form_create_user_event()   X-Ref
A user with the moodle/calendar:manageownentries capability at the
system context should be able to create a user event.


test_submit_create_update_form_create_user_event_no_permission()   X-Ref
A user without the moodle/calendar:manageownentries capability at the
system context should not be able to create a user event.


test_submit_create_update_form_create_site_event()   X-Ref
A user with the moodle/calendar:manageentries capability at the
site course context should be able to create a site event.


test_submit_create_update_form_create_site_event_no_permission()   X-Ref
A user without the moodle/calendar:manageentries capability at the
site course context should not be able to create a site event.


test_submit_create_update_form_create_course_event()   X-Ref
A user that has the moodle/calendar:manageentries in a course that they
are enrolled in should be able to create a course event in that course.


test_submit_create_update_form_create_course_event_no_permission()   X-Ref
A user without the moodle/calendar:manageentries capability in a course
that they are enrolled in should not be able to create a course event in that course.


test_submit_create_update_form_create_course_event_not_enrolled()   X-Ref
A user should not be able to create an event for a course that they are
not enrolled in.


test_submit_create_update_form_create_group_event_group_member_manage_course()   X-Ref
A user should be able to create an event for a group that they are a member of in
a course in which they are enrolled and have the moodle/calendar:manageentries capability.


test_submit_create_update_form_create_group_event_group_member_manage_group_entries()   X-Ref
A user should be able to create an event for a group that they are a member of in
a course in which they are enrolled and have the moodle/calendar:managegroupentries capability.


test_submit_create_update_form_create_group_event_access_all_groups()   X-Ref
A user should be able to create an event for any group in a course in which
they are enrolled and have the moodle/site:accessallgroups capability.


test_submit_create_update_form_create_group_event_non_member_no_permission()   X-Ref
A user should not be able to create an event for any group that they are not a
member of in a course in which they are enrolled but don't have the
moodle/site:accessallgroups capability.


test_get_calendar_monthly_view_no_course_permission()   X-Ref
A user should not be able load the calendar monthly view for a course they cannot access.


test_get_calendar_monthly_view_with_day_provided()   X-Ref
Test get_calendar_monthly_view when a day parameter is provided.


test_get_calendar_day_view_no_course_permission()   X-Ref
A user should not be able load the calendar day view for a course they cannot access.


test_get_calendar_upcoming_view_no_course_permission()   X-Ref
A user should not be able load the calendar upcoming view for a course they cannot access.


test_get_calendar_event_by_id_no_course_permission()   X-Ref
A user should not be able load the calendar event for a course they cannot access.


get_calendar_event_by_id_prevent_read_other_users_events_data_provider()   X-Ref
User data for testing reading calendar events.

return: array

test_get_calendar_event_by_id_prevent_read_other_users_events(bool $isadminevent, bool $isadmin, ?\stdClass $readerrolecontext,?string $readerrolename, bool $expectexception)   X-Ref
Prevent user from reading other user's event.

param: bool          $isadminevent      Is admin's event
param: bool          $isadmin           Is current user admin user
param: null|stdClass $readerrolecontext Reader role context
param: null|string   $readerrolename    Role name
param: bool          $expectexception   Should the test throw exception

edit_or_delete_other_users_events_data_provider()   X-Ref
User data for testing editing or deleting calendar events.

return: array

test_delete_other_users_events(bool $isadmin, bool $isadminevent,?\stdClass $writerrolecontext, ?string $writerrolename, bool $expectexception)   X-Ref
Test the behavior of deleting other users' user events.

param: bool          $isadmin Whether the current user is admin.
param: bool          $isadminevent Whether it's an admin event or not.
param: stdClass|null $writerrolecontext The reader role context.
param: string|null   $writerrolename The role name.
param: bool          $expectexception Whether the test should throw an exception or not.

test_edit_other_users_events(bool $isadmin, bool $isadminevent,?\stdClass $writerrolecontext, ?string $writerrolename, bool $expectexception)   X-Ref
Test the behavior of editing other users' user events

param: bool          $isadmin Whether the current user is admin.
param: bool          $isadminevent Whether it's an admin event or not.
param: stdClass|null $writerrolecontext The reader role context.
param: string|null   $writerrolename The role name.
param: bool          $expectexception Whether the test should throw an exception or not.

test_get_calendar_events_hidden_category()   X-Ref
A user should not be able load the calendar events for a category they cannot see.


test_get_calendar_access_information_for_admins()   X-Ref
Test get_calendar_access_information for admins.


test_get_calendar_access_information_for_authenticated_users()   X-Ref
Test get_calendar_access_information for authenticated users.


test_get_calendar_access_information_for_student_users()   X-Ref
Test get_calendar_access_information for student users.


test_get_calendar_access_information_for_teacher_users()   X-Ref
Test get_calendar_access_information for teacher users.


test_get_allowed_event_types_for_admins()   X-Ref
Test get_allowed_event_types for admins.


test_get_allowed_event_types_for_authenticated_users()   X-Ref
Test get_allowed_event_types for authenticated users.


test_get_allowed_event_types_for_student_users()   X-Ref
Test get_allowed_event_types for student users.


test_get_allowed_event_types_for_teacher_users()   X-Ref
Test get_allowed_event_types for teacher users.


test_get_timestamps_string_keys()   X-Ref
Test get_timestamps with string keys, with and without optional hour/minute values.


test_get_timestamps_no_keys()   X-Ref
Test get_timestamps with no keys specified, with and without optional hour/minute values.