Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

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: 1491 lines (67 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: core_enrollib_testcase  - 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_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