Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

Test non-plugin enrollib parts.

Copyright: 2012 Petr Skoda {@link http://skodak.org}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1736 lines (77 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: enrollib_test  - X-Ref

Test non-plugin enrollib parts.

test_enrol_get_all_users_courses()   X-Ref
No description

test_enrol_course_delete_without_userid()   X-Ref
Test enrol_course_delete() without passing a user id. When a value for user id is not present, the method
should delete all enrolment related data in the course.


test_enrol_course_delete_with_userid($excludedcapabilities, $expected)   X-Ref
Test enrol_course_delete() when user id is present.
When a value for user id is present, the method should make sure the user has the proper capability to
un-enrol users before removing the enrolment data. If the capabilities are missing the data should not be removed.

param: array $excludedcapabilities The capabilities that should be excluded from the user's role
param: bool $expected The expected results

enrol_course_delete_with_userid_provider()   X-Ref
Data provider for test_enrol_course_delete_with_userid().

return: array

test_enrol_user_sees_own_courses()   X-Ref
No description

test_enrol_get_shared_courses()   X-Ref
No description

test_enrol_get_shared_courses_different_methods()   X-Ref
No description

test_user_enrolment_created_event()   X-Ref
Test user enrolment created event.


test_user_enrolment_deleted_event()   X-Ref
Test user_enrolment_deleted event.


test_instance_events()   X-Ref
Test enrol_instance_created, enrol_instance_updated and enrol_instance_deleted events.


test_enrollment_update_timemodified()   X-Ref
Confirms that timemodified field was updated after modification of user enrollment


test_enrol_get_my_courses_only_enrolled_courses()   X-Ref
Test to confirm that enrol_get_my_courses only return the courses that
the logged in user is enrolled in.


test_enrol_get_my_courses_include_hidden()   X-Ref
Tests the enrol_get_my_courses function when using the $includehidden parameter, which
should remove any courses hidden from the user's timeline


test_enrol_get_my_courses_all_accessible()   X-Ref
Tests the enrol_get_my_courses function when using the $allaccessible parameter, which
includes a wider range of courses (enrolled courses + other accessible ones).


enrol_get_my_courses_by_time_provider()   X-Ref
Data provider for {@see test_enrol_get_my_courses_by_time}

return: array

test_enrol_get_my_courses_by_time(?int $timestartoffset, ?int $timeendoffset, bool $expectreturn)   X-Ref
Test that expected course enrolments are returned when they have timestart / timeend specified

param: int|null $timestartoffset Null for 0, otherwise offset from current time
param: int|null $timeendoffset Null for 0, otherwise offset from current time
param: bool $expectreturn

test_course_users()   X-Ref
test_course_users

return: void

test_course_users_in_groups()   X-Ref
test_course_users in groups

return: void

test_count_enrolled_users()   X-Ref
Test count of enrolled users

return: void

get_enrol_get_my_courses_sort_by_last_access_test_cases()   X-Ref
Test cases for the test_enrol_get_my_courses_sort_by_last_access test.


test_enrol_get_my_courses_sort_by_last_access($enrolledcoursesdata,$unenrolledcoursesdata,$sort,$limit,$offset,$expectedcourses)   X-Ref
Test the get_enrolled_courses_by_timeline_classification function.

param: array $enrolledcoursesdata Courses to create and enrol the user in
param: array $unenrolledcoursesdata Courses to create nut not enrol the user in
param: string $sort Sort string for the enrol function
param: int $limit Maximum number of results
param: int $offset Offset the courses result set by this amount
param: array $expectedcourses Expected courses in result

test_enrol_get_course_users_roles()   X-Ref
Test enrol_get_course_users_roles function.

return: void

test_enrol_calculate_duration()   X-Ref
Test enrol_calculate_duration function


test_get_enrolled_with_capabilities_join_cannotmatchanyrows(string $capability,bool $useprohibit,int $expectedmatch,int $expectedcount)   X-Ref
Test get_enrolled_with_capabilities_join cannotmatchanyrows attribute.

param: string $capability the tested capability
param: bool $useprohibit if the capability must be assigned to prohibit
param: int $expectedmatch expected cannotmatchanyrows value
param: int $expectedcount expceted count value

get_enrolled_with_capabilities_join_cannotmatchanyrows_data()   X-Ref
Data provider for test_get_enrolled_with_capabilities_join_cannotmatchanyrows

return: @array of testing scenarios

test_enrol_check_plugins_with_forced_option()   X-Ref
Test last_time_enrolments_synced not recorded with "force" option for enrol_check_plugins.


empty_config_data_provider()   X-Ref
Data provided for test_enrol_check_plugins_with_empty_config_value test.

return: array

test_enrol_check_plugins_with_empty_config_value($config)   X-Ref
Test that empty 'enrolments_sync_interval' is treated as forced option for enrol_check_plugins.

param: mixed $config Config value.

test_last_time_enrolments_synced_is_set_if_not_forced()   X-Ref
Test last_time_enrolments_synced is recorded without "force" option for enrol_check_plugins.


test_last_time_enrolments_synced_is_set_if_not_forced_if_have_not_passed_interval()   X-Ref
Test last_time_enrolments_synced is recorded correctly without "force" option for enrol_check_plugins.


test_enrol_selfenrol_available()   X-Ref
Test enrol_selfenrol_available function behavior.