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

Defines 1 class

expired_contexts_test:: (71 methods):
  setup_basics()
  create_and_set_purpose_for_contextlevel()
  test_flag_not_setup()
  test_flag_user_no_lastaccess()
  test_flag_user_recent_lastaccess()
  test_flag_user_past_lastaccess()
  test_flag_user_past_lastaccess_still_enrolled()
  test_flag_user_update_existing()
  test_flag_user_past_lastaccess_unexpired_past_enrolment()
  test_flag_user_past_override_role()
  test_flag_user_past_lastaccess_expired_enrolled()
  test_flag_user_past_lastaccess_missing_enddate_required()
  test_flag_user_past_lastaccess_missing_enddate_not_required()
  test_flag_user_recent_lastaccess_existing_record()
  test_flag_user_retention_changed()
  test_flag_user_historic_block_unapproved()
  test_flag_user_historic_unexpired_child()
  test_flag_course_no_enddate()
  test_flag_course_past_enddate_future_child()
  test_flag_course_past_enddate()
  test_flag_course_past_enddate_multiple()
  test_flag_course_future_enddate()
  test_flag_course_recent_unexpired_enddate()
  test_flag_course_past_enddate_with_override_unexpired_role()
  test_flag_course_past_enddate_with_override_expired_role()
  test_flag_course_override_expiredwith_override_unexpired_on_child()
  test_process_user_context_with_override_unexpired_role()
  test_process_course_context_with_override_unexpired_role()
  test_process_course_context_with_override_expired_role()
  test_process_course_context_with_user_in_both_lists()
  test_process_course_context_with_user_in_both_lists_expired()
  test_process_not_setup()
  test_process_none_approved()
  test_process_no_context()
  test_process_user_context()
  test_process_course_context()
  test_process_user_context_logged_in_after_approval()
  test_process_user_context_changed_after_approved()
  test_process_user_historic_block_unapproved()
  test_process_user_historic_unexpired_child()
  test_process_course_context_updated()
  test_process_course_context_outstanding_children()
  test_process_course_context_pending_children()
  test_process_course_context_approved_children()
  test_can_process_deletion()
  can_process_deletion_provider()
  test_is_complete()
  is_complete_provider()
  test_is_fully_expired()
  is_fully_expired_provider()
  test_orphaned_records_are_cleared()
  test_progress_tracer_default()
  test_progress_tracer_set()
  create_user_block()
  create_block()
  construct_user_page()
  get_last_block_on_page()
  test_is_context_expired_system()
  test_is_context_expired_user_block()
  test_is_context_expired_frontpage()
  test_is_context_expired_course_expired()
  test_is_context_expired_course_unexpired()
  test_is_child_context_expired_course_unexpired_with_child()
  test_is_context_expired_course_expired_override()
  test_is_context_expired_course_expired_override_parent()
  test_is_context_expired_course_expired_override_parent_no_role()
  test_is_context_expired_course_expired_override_inverse()
  test_is_context_expired_course_expired_override_inverse_parent()
  test_is_context_expired_course_expired_override_inverse_parent_not_assigned()
  test_is_context_expired_or_unprotected_for_user_role_mixtures_protected()
  test_is_context_expired_or_unprotected_for_user_role_mixtures_protected_inverse()


Class: expired_contexts_test  - X-Ref

Expired contexts tests.

setup_basics(string $system, string $user, string $course = null, string $activity = null)   X-Ref
Setup the basics with the specified retention period.

param: string  $system Retention policy for the system.
param: string  $user Retention policy for users.
param: string  $course Retention policy for courses.
param: string  $activity Retention policy for activities.

create_and_set_purpose_for_contextlevel(string $retention, int $contextlevel)   X-Ref
Create a retention period and set it for the specified context level.

param: string  $retention
param: int     $contextlevel
return: purpose

test_flag_not_setup()   X-Ref
Ensure that a user with no lastaccess is not flagged for deletion.


test_flag_user_no_lastaccess()   X-Ref
Ensure that a user with no lastaccess is not flagged for deletion.


test_flag_user_recent_lastaccess()   X-Ref
Ensure that a user with a recent lastaccess is not flagged for deletion.


test_flag_user_past_lastaccess()   X-Ref
Ensure that a user with a lastaccess in the past is flagged for deletion.


test_flag_user_past_lastaccess_still_enrolled()   X-Ref
Ensure that a user with a lastaccess in the past but active enrolments is not flagged for deletion.


test_flag_user_update_existing()   X-Ref
Ensure that a user with a lastaccess in the past and no active enrolments is flagged for deletion.


test_flag_user_past_lastaccess_unexpired_past_enrolment()   X-Ref
Ensure that a user with a lastaccess in the past and expired enrolments.


test_flag_user_past_override_role()   X-Ref
Ensure that a user with a lastaccess in the past and expired enrolments.


test_flag_user_past_lastaccess_expired_enrolled()   X-Ref
Ensure that a user with a lastaccess in the past and expired enrolments.


test_flag_user_past_lastaccess_missing_enddate_required()   X-Ref
Ensure that a user with a lastaccess in the past and enrolments without a course end date are respected
correctly.


test_flag_user_past_lastaccess_missing_enddate_not_required()   X-Ref
Ensure that a user with a lastaccess in the past and enrolments without a course end date are respected
correctly when the end date is not required.


test_flag_user_recent_lastaccess_existing_record()   X-Ref
Ensure that a user with a recent lastaccess is not flagged for deletion.


test_flag_user_retention_changed()   X-Ref
Ensure that a user with a recent lastaccess is not flagged for deletion.


test_flag_user_historic_block_unapproved()   X-Ref
Ensure that a user with a historically expired expired block record child is cleaned up.


test_flag_user_historic_unexpired_child()   X-Ref
Ensure that a user with a block which has a default retention period which has not expired, is still expired.


test_flag_course_no_enddate()   X-Ref
Ensure that a course with no end date is not flagged.


test_flag_course_past_enddate_future_child()   X-Ref
Ensure that a course with an end date in the distant past, but a child which is unexpired is not flagged.


test_flag_course_past_enddate()   X-Ref
Ensure that a course with an end date in the distant past is flagged.


test_flag_course_past_enddate_multiple()   X-Ref
Ensure that a course with an end date in the distant past is flagged.


test_flag_course_future_enddate()   X-Ref
Ensure that a course with an end date in the future is not flagged.


test_flag_course_recent_unexpired_enddate()   X-Ref
Ensure that a course with an end date in the future is not flagged.


test_flag_course_past_enddate_with_override_unexpired_role()   X-Ref
Ensure that a course with an end date in the distant past is flagged, taking into account any purpose override


test_flag_course_past_enddate_with_override_expired_role()   X-Ref
Ensure that a course with an end date in the distant past is flagged, and any expired role is ignored.


test_flag_course_override_expiredwith_override_unexpired_on_child()   X-Ref
Ensure that where a course has explicitly expired one role, but that role is explicitly not expired in a child
context, does not have the parent context role expired.


test_process_user_context_with_override_unexpired_role()   X-Ref
Ensure that a user context previously flagged as approved is not removed if the user has any unexpired roles.


test_process_course_context_with_override_unexpired_role()   X-Ref
Ensure that a module context previously flagged as approved is removed with appropriate unexpiredroles kept.


test_process_course_context_with_override_expired_role()   X-Ref
Ensure that a module context previously flagged as approved is removed with appropriate expiredroles kept.


test_process_course_context_with_user_in_both_lists()   X-Ref
Ensure that a module context previously flagged as approved is removed with appropriate expiredroles kept.


test_process_course_context_with_user_in_both_lists_expired()   X-Ref
Ensure that a module context previously flagged as approved is removed with appropriate expiredroles kept.


test_process_not_setup()   X-Ref
Ensure that a site not setup will not process anything.


test_process_none_approved()   X-Ref
Ensure that a user with no lastaccess is not flagged for deletion.


test_process_no_context()   X-Ref
Ensure that a user with no lastaccess is not flagged for deletion.


test_process_user_context()   X-Ref
Ensure that a user context previously flagged as approved is removed.


test_process_course_context()   X-Ref
Ensure that a course context previously flagged as approved is removed.


test_process_user_context_logged_in_after_approval()   X-Ref
Ensure that a user context previously flagged as approved is not removed if the user then logs in.


test_process_user_context_changed_after_approved()   X-Ref
Ensure that a user context previously flagged as approved is not removed if the purpose has changed.


test_process_user_historic_block_unapproved()   X-Ref
Ensure that a user with a historically expired expired block record child is cleaned up.


test_process_user_historic_unexpired_child()   X-Ref
Ensure that a user with a block which has a default retention period which has not expired, is still expired.


test_process_course_context_updated()   X-Ref
Ensure that a course context previously flagged as approved for deletion which now has an unflagged child, is
updated.


test_process_course_context_outstanding_children()   X-Ref
Ensure that a course context previously flagged as approved for deletion which now has an unflagged child, is
updated.


test_process_course_context_pending_children()   X-Ref
Ensure that a course context previously flagged as approved for deletion which now has an unflagged child, is
updated.


test_process_course_context_approved_children()   X-Ref
Ensure that a course context previously flagged as approved for deletion which now has an unflagged child, is
updated.


test_can_process_deletion($status, $expected)   X-Ref
Test that the can_process_deletion function returns expected results.

param: int     $status
param: bool    $expected

can_process_deletion_provider()   X-Ref
Data provider for the can_process_deletion tests.

return: array

test_is_complete($status, $expected)   X-Ref
Test that the is_complete function returns expected results.

param: int     $status
param: bool    $expected

is_complete_provider()   X-Ref
Data provider for the is_complete tests.

return: array

test_is_fully_expired($record, $expected)   X-Ref
Test that the is_fully_expired function returns expected results.

param: array   $record
param: bool    $expected

is_fully_expired_provider()   X-Ref
Data provider for the is_fully_expired tests.

return: array

test_orphaned_records_are_cleared()   X-Ref
Ensure that any orphaned records are removed once the context has been removed.


test_progress_tracer_default()   X-Ref
Ensure that the progres tracer works as expected out of the box.


test_progress_tracer_set()   X-Ref
Ensure that the progres tracer works as expected when given a specific traer.


create_user_block($title, $body, $format)   X-Ref
Creates an HTML block on a user.

param: string  $title
param: string  $body
param: string  $format
return: \block_instance

create_block($page)   X-Ref
Creates an HTML block on a page.

param: \page $page Page

construct_user_page(\stdClass $user)   X-Ref
Constructs a Page object for the User Dashboard.

param: \stdClass       $user User to create Dashboard for.
return: \moodle_page

get_last_block_on_page($page)   X-Ref
Get the last block on the page.

param: \page $page Page
return: \block_html Block instance object

test_is_context_expired_system()   X-Ref
Test the is_context_expired functions when supplied with the system context.


test_is_context_expired_user_block()   X-Ref
Test the is_context_expired functions when supplied with a block in the user context.

Children of a user context always follow the user expiry rather than any context level defaults (e.g. at the
block level.

test_is_context_expired_frontpage()   X-Ref
Test the is_context_expired functions when supplied with the front page course.


test_is_context_expired_course_expired()   X-Ref
Test the is_context_expired functions when supplied with an expired course.


test_is_context_expired_course_unexpired()   X-Ref
Test the is_context_expired functions when supplied with an unexpired course.


test_is_child_context_expired_course_unexpired_with_child()   X-Ref
Test the is_context_expired functions when supplied with an unexpired course and a child context in the course which is protected.

When a child context has a specific purpose set, then that purpose should be respected with respect to the
course.

If the course is still within the expiry period for the child context, then that child's protected flag should be
respected, even when the course may have expired.

test_is_context_expired_course_expired_override()   X-Ref
Test the is_context_expired functions when supplied with an expired course which has role overrides.


test_is_context_expired_course_expired_override_parent()   X-Ref
Test the is_context_expired functions when supplied with an expired course which has role overrides.


test_is_context_expired_course_expired_override_parent_no_role()   X-Ref
Test the is_context_expired functions when supplied with an expired course which has role overrides but the user
does not hold the role.


test_is_context_expired_course_expired_override_inverse()   X-Ref
Test the is_context_expired functions when supplied with an unexpired course which has role overrides.


test_is_context_expired_course_expired_override_inverse_parent()   X-Ref
Test the is_context_expired functions when supplied with an unexpired course which has role overrides.


test_is_context_expired_course_expired_override_inverse_parent_not_assigned()   X-Ref
Test the is_context_expired functions when supplied with an unexpired course which has role overrides.


test_is_context_expired_or_unprotected_for_user_role_mixtures_protected()   X-Ref
Ensure that context expired checks for a specific user taken into account roles.


test_is_context_expired_or_unprotected_for_user_role_mixtures_protected_inverse()   X-Ref
Ensure that context expired checks for a specific user taken into account roles when retention is inversed.