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.

Class: sync_members_test  - X-Ref

Tests for the enrol_lti\local\ltiadvantage\task\sync_members scheduled task.

verify_user_profile_image(int $userid, bool $match = true)   X-Ref
Verify the user's profile picture has been set, which is useful to verify picture syncs.

param: int $userid the id of the Moodle user.
param: bool $match true to verify a match, false to verify a non-match.

get_mock_members_with_ids(array $userids, ?array $legacyuserids = null, $names = true,$emails = true, bool $linklevel = true, bool $picture = false, array $roles = [])   X-Ref
Helper to get a list of mocked member entries for use in the mocked sync task.

param: array $userids the array of lti user ids to use.
param: array|null $legacyuserids legacy user ids for the lti11_legacy_user_id property, null if not desired.
param: bool $names whether to include names in the user data or not.
param: bool $emails whether to include email in the user data or not.
param: bool $linklevel whether to mock the user return data at link-level (true) or context-level (false).
param: bool $picture whether to mock a user's picture field in the return data.
param: array $roles an array of IMS roles to include with each member which, if empty, defaults to just the learner role.
return: array the array of users.

get_mock_task_resource_link_level(array $resourcelinks = [])   X-Ref
Gets a task mocked to only support resource-link-level memberships request.

param: array $resourcelinks array for stipulating per link users, containing list of [resourcelink, members].
return: sync_members|\PHPUnit\Framework\MockObject\MockObject

get_mock_task_context_level()   X-Ref
Gets a task mocked to only support context-level memberships request.

return: sync_members|\PHPUnit\Framework\MockObject\MockObject

get_mock_task_with_users(array $users)   X-Ref
Gets a sync task, with the remote calls mocked to return the supplied users.

See get_mock_members_with_ids() for generating the users for input.

param: array $users a list of users, the result of a call to get_mock_members_with_ids().
return: \PHPUnit\Framework\MockObject\MockObject the mock task.

verify_course_enrolments(\stdClass $course, array $ltiusers)   X-Ref
Check that all the given ltiusers are enrolled in the course.

param: \stdClass $course the course instance.
param: user[] $ltiusers array of lti user instances.

test_get_name()   X-Ref
Test confirming task name.


test_resource_link_level_sync()   X-Ref
Test a resource-link-level membership sync, confirming that all relevant domain objects are updated properly.


test_resource_link_level_sync_multiple_resource_links()   X-Ref
Test a resource-link-level membership sync when there are more than one resource links for the resource.


test_user_profile_image_sync()   X-Ref
Verify the task will update users' profile pictures if the 'picture' member field is provided.


test_context_level_sync()   X-Ref
Test a context-level membership sync, confirming that all relevant domain objects are updated properly.


test_sync_user_data()   X-Ref
Test verifying the sync task handles the omission/inclusion of PII information for users.


test_membership_sync_disabled()   X-Ref
Test verifying the task won't sync members for shared resources having member sync disabled.


test_sync_mode_enrol_and_unenrol()   X-Ref
Test verifying the sync task for resources configured as 'helper::MEMBER_SYNC_ENROL_AND_UNENROL'.


test_sync_mode_unenrol_missing()   X-Ref
Confirm the sync task operation for resources configured as 'helper::MEMBER_SYNC_UNENROL_MISSING'.


test_sync_mode_enrol_new()   X-Ref
Confirm the sync task operation for resources configured as 'helper::MEMBER_SYNC_ENROL_NEW'.


test_sync_auth_disabled()   X-Ref
Test confirming that no changes take place if the auth_lti plugin is not enabled.


test_sync_enrol_disabled()   X-Ref
Test confirming that no sync takes place when the enrol_lti plugin is not enabled.


test_sync_members_disabled_instance()   X-Ref
Test syncing members when the enrolment instance is disabled.


test_sync_no_nrps_support()   X-Ref
Test syncing members for a membersync-enabled resource when the launch omits the NRPS service endpoints.


test_sync_non_lti_linked_user()   X-Ref
Test confirming that preexisting, non-lti user accounts do not have their profiles or pictures updated during sync.


test_sync_enrolments_and_migration(?array $legacydata, ?array $resourceconfig, array $launchdata,?array $syncmembers, array $expected)   X-Ref
Test the member sync for a range of scenarios including migrated tools, unlaunched tools, provisioning methods.

param: array|null $legacydata array detailing what legacy information to create, or null if not required.
param: array|null $resourceconfig array detailing config values to be used when creating the test enrol_lti instances.
param: array $launchdata array containing details of the launch, including user and migration claim.
param: array|null $syncmembers the members to use in the mock sync.
param: array $expected the array detailing expectations.

member_sync_data_provider()   X-Ref
Data provider for member syncs.

return: array[] the array of test data.