Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

A collection of tests for accesslib::has_capability().

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

Defines 1 class


Class: accesslib_has_capability_test  - X-Ref

Unit tests tests for has_capability.

test_locked_contexts($lockedcontexts, $blocked)   X-Ref
Unit tests to check the operation of locked contexts.

Note: We only check the admin user here.
If the admin cannot do it, then no-one can.

param: string[]    $lockedcontexts The list of contexts, by name, to mark as locked
param: string[]    $blocked The list of contexts which will be 'blocked' by has_capability

test_locked_contexts_for_admin_with_config($lockedcontexts, $blocked)   X-Ref
Unit tests to check the operation of locked contexts.

Note: We only check the admin user here.
If the admin cannot do it, then no-one can.

param: string[]    $lockedcontexts The list of contexts, by name, to mark as locked
param: string[]    $blocked The list of contexts which will be 'blocked' by has_capability

locked_context_provider()   X-Ref
Data provider for testing that has_capability() deals with locked contexts.

return: array

login_as_provider()   X-Ref
Data provider for for has_capability tests when logged in as a different user.

return: array

test_login_as_admin(string $loginascontext, array $testcontexts)   X-Ref
Test that the log in as functionality works as expected for an administrator.

An administrator logged in as another user assumes all of their capabilities.

param: string $loginascontext
param: array  $testcontexts

test_login_as_user(string $loginascontext, array $testcontexts)   X-Ref
Test that the log in as functionality works as expected for a regulr user.

param: string $loginascontext
param: array  $testcontexts

get_test_data()   X-Ref
Get the test data contexts.

return: stdClass