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.

Unit Tests for the abstract contextlist Class

Copyright: 2018 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 305 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes


Class: contextlist_base_test  - X-Ref

Tests for the \core_privacy API's contextlist base functionality.

test_get_contextids($input, $expected, $count)   X-Ref
Ensure that get_contextids returns the list of unique contextids.

param: array   $input List of context IDs
param: array   $expected list of contextids
param: int     $count Expected count

get_contextids_provider()   X-Ref
Provider for the list of contextids.

return: array

test_get_contexts()   X-Ref
Ensure that get_contexts returns the correct list of contexts.


test_countable($input, $expected, $count)   X-Ref
Ensure that the contextlist_base is countable.

param: array   $input List of context IDs
param: array   $expected list of contextids
param: int     $count Expected count

test_context_iteration()   X-Ref
Ensure that the contextlist_base iterates over the set of contexts.


test_current_context_one_context()   X-Ref
Test that deleting a context results in current returning nothing.


test_current_context_two_contexts()   X-Ref
Test that deleting a context results in the next record being returned.


test_get_contexts_all_deleted()   X-Ref
Test that if there are no non-deleted contexts that nothing is returned.


test_get_contexts_one_deleted()   X-Ref
Test that get_contexts() returns only active contexts.


Class: test_contextlist_base  - X-Ref

A test class extending the contextlist_base allowing setting of the
contextids.

set_contextids(array $contextids)   X-Ref
Set the contextids for the test class.

param: int[]   $contexids  The list of contextids to use.