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 310 and 311] [Versions 39 and 311]

Tests for the tool_provider class.

Copyright: 2016 Jun Pataleta <jun@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 670 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 classes


Class: tool_provider_test  - 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