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.

Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

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

Defines 1 class


Class: accesslib_has_capability_testcase  - 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: string $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: string $testcontexts

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

return: stdClass