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.

Differences Between: [Versions 401 and 402] [Versions 401 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: 6 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'.