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.

(no description)

File Size: 552 lines (21 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: user_repository_test  - X-Ref

Tests for user_repository objects.

generate_user(int $mockresourceid = 1, array $userfields = [])   X-Ref
Helper to generate a new user instance.

param: int $mockresourceid used to spoof a published resource, to which this user is associated.
param: array $userfields user information like city, timezone which would normally come from the tool configuration.
return: user a user instance

assert_same_user_values(user $expected, user $check, bool $checkresourcelink = false)   X-Ref
Helper to assert that all the key elements of two users (i.e. excluding id) are equal.

param: user $expected the user whose values are deemed correct.
param: user $check the user to check.
param: bool $checkresourcelink whether or not to confirm the resource link value matches too.

assert_user_db_values(user $expected)   X-Ref
Helper to assert that all the key elements of a user are present in the DB.

param: user $expected the user whose values are deemed correct.

test_save_new_unchanged_user_defaults()   X-Ref
Tests adding a user to the store, assuming that the user has been created using the default 'user default values'.


test_save_new_changed_user_defaults()   X-Ref
Tests adding a user to the store, assuming that the user has been created using modified 'user default values'.


test_save_existing()   X-Ref
Test saving an existing user instance.


test_save_existing_localid_mismatch()   X-Ref
Test saving an instance which exists by id, but has a different localid to the data in the store.


test_save_stale_id()   X-Ref
Test trying to save a user with an id that is invalid.


test_save_uniqueness_constraint()   X-Ref
Verify that trying to save a stale object results in an exception referring to unique constraint violation.


test_find()   X-Ref
Test finding a user instance by id.


test_find_by_resource()   X-Ref
Test finding all of users associated with a given published resource.


test_find_by_resource_link()   X-Ref
Test that users can be found based on their resource_link association.


test_exists()   X-Ref
Test checking existence of a user instance, based on id.


test_delete()   X-Ref
Test deleting a user instance, based on id.


test_delete_by_deployment()   X-Ref
Test deleting a collection of lti user instances by deployment.


test_save_deleted()   X-Ref
Verify a user who has been deleted can be re-saved to the repository and matched to an existing local user.


test_find_filters_legacy_lti_users()   X-Ref
Test confirming that any associated legacy lti user records are not returned by the repository.

This test ensures that any enrolment methods (resources) updated in-place from legacy LTI to 1.3 only return LTI 1.3 users.