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 311 and 402] [Versions 311 and 403]

This file contains helper classes for testing the web service and external files.

Copyright: 2012 Jerome Mouneyrac
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 138 lines (5 kb)
Included or required:0 times
Referenced: 17 times
Includes or requires: 0 files

Defines 1 class

externallib_advanced_testcase:: (3 methods):
  assignUserCapability()
  configure_filters()
  unassignUserCapability()


Class: externallib_advanced_testcase  - X-Ref

Helper base class for external tests. Helpfull to test capabilities.

assignUserCapability($capability, $contextid, $roleid = null)   X-Ref
Assign a capability to $USER
The function creates a student $USER if $USER->id is empty

param: string $capability capability name
param: int $contextid
param: int $roleid
return: int the role id - mainly returned for creation, so calling function can reuse it

configure_filters($filters)   X-Ref
Configure some filters for external tests.

param: array $filters Filters to enable. Each filter should contain:

unassignUserCapability($capability, $contextid = null, $roleid = null, $courseid = null, $enrol = 'manual')   X-Ref
Unassign a capability to $USER.

param: string $capability capability name.
param: int $contextid set the context id if you used assignUserCapability.
param: int $roleid set the role id if you used assignUserCapability.
param: int $courseid set the course id if you used getDataGenerator->enrol_users.
param: string $enrol set the enrol plugin name if you used getDataGenerator->enrol_users with a different plugin than 'manual'.