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.

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.