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.

Class: tool_provider_testcase  - X-Ref

Tests for the tool_provider class.

setUp()   X-Ref
Test set up.

This is executed before running any tests in this file.

test_constructor_with_non_existent_tool()   X-Ref
Passing non-existent tool ID.


test_constructor()   X-Ref
Constructor test.


test_handle_request_no_request_data()   X-Ref
Test for handle request.


test_on_error()   X-Ref
Test for tool_provider::onError().


test_on_register_no_consumer()   X-Ref
Test for tool_provider::onRegister() with no tool consumer set.


test_on_register_no_return_url()   X-Ref
Test for tool_provider::onRegister() without return URL.


test_on_register_failed()   X-Ref
Test for tool_provider::onRegister() when registration fails.


test_on_register()   X-Ref
Test for tool_provider::onRegister() when registration succeeds.


test_on_launch_no_frame_embedding()   X-Ref
Test for tool_provider::onLaunch().


test_on_launch_with_frame_embedding()   X-Ref
Test for tool_provider::onLaunch().


test_on_launch_with_invalid_secret_and_no_proxy()   X-Ref
Test for tool_provider::onLaunch() with invalid secret and no tool proxy (for LTI 1 launches).


test_on_launch_proxy_with_invalid_launch_url()   X-Ref
Test for tool_provider::onLaunch() with invalid launch URL.


test_on_launch_proxy_with_valid_launch_url()   X-Ref
Test for tool_provider::onLaunch() with invalid launch URL.


test_on_launch_proxy_with_invalid_message_type()   X-Ref
Test for tool_provider::onLaunch() for a request with message type other than basic-lti-launch-request.


test_on_launch_with_user_image_from_resource_link()   X-Ref
Test for tool_provider::onLaunch() to verify that a user image can be set from the resource link's custom_user_image setting.


test_on_launch_user_enrolment()   X-Ref
Test for tool_provider::onLaunch() to verify that a LTI user has been enrolled.


test_on_launch_no_consumer()   X-Ref
Test for tool_provider::onLaunch() when the consumer object has not been set.


test_on_launch_invalid_consumer()   X-Ref
Test for tool_provider::onLaunch() when we have a non-existent consumer data.


test_map_tool_to_consumer()   X-Ref
Test for tool_provider::map_tool_to_consumer().


test_map_tool_to_consumer_no_consumer()   X-Ref
Test for tool_provider::map_tool_to_consumer().


build_dummy_tp($secret = null, $proxy = null, $resourcelinksettings = null)   X-Ref
Builds a dummy tool provider object.

param: string $secret Consumer secret.
param: array|stdClass $proxy Tool proxy data.
param: null $resourcelinksettings Key-value array for resource link settings.
return: dummy_tool_provider

Class: dummy_tool_provider  - X-Ref

Class dummy_tool_provider.

A class that extends tool_provider so that we can expose the protected methods that we have overridden.

onError()   X-Ref
Exposes tool_provider::onError().


onLaunch()   X-Ref
Exposes tool_provider::onLaunch().


onRegister()   X-Ref
Exposes tool_provider::onRegister().


get_error_output()   X-Ref
Expose protected variable errorOutput.

return: string

Class: dummy_tool_consumer  - X-Ref

Class dummy_tool_consumer

A class that extends ToolConsumer in order to override and simulate sending and receiving data to tool consumer endpoint.

__construct($key = null, $dataconnector = null, $autoenable = false, $success = false)   X-Ref
dummy_tool_consumer constructor.

param: null|string $key
param: mixed|null $dataconnector
param: bool $autoenable
param: bool $success

doServiceRequest($service, $method, $format, $data)   X-Ref
Override ToolConsumer::doServiceRequest() to simulate sending/receiving data to and from the tool consumer.

param: object $service
param: string $method
param: string $format
param: mixed $data
return: HTTPMessage