Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]

This file contains unit tests for (some of) lti/locallib.php

Author: Charles Severance csev@unmich.edu
Author: Marc Alier (marc.alier@upc.edu)
Author: Jordi Piguillem
Author: Nikolas Galanis
Author: Chris Scribner
Copyright: 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
Copyright: 2009 Universitat Politecnica de Catalunya http://www.upc.edu
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1575 lines (62 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

mod_lti_locallib_testcase:: (38 methods):
  test_split_custom_parameters()
  disabled_test_sign_parameters()
  disabled_test_parse_grade_replace_message()
  test_lti_ensure_url_is_https()
  test_lti_get_url_thumbprint()
  test_lti_buid_request_resource_link_id()
  test_lti_build_request_description()
  test_lti_prepare_type_for_save_forcessl()
  test_lti_load_type_from_cartridge()
  test_lti_load_tool_from_cartridge()
  test_lti_build_content_item_selection_request()
  test_lti_build_content_item_selection_request_invalid_tooltype()
  test_lti_build_content_item_selection_request_invalid_mediatypes()
  test_lti_build_content_item_selection_request_invalid_presentationtargets()
  lti_get_best_tool_by_url_provider()
  test_lti_get_best_tool_by_url()
  test_lti_get_jwt_message_type_mapping()
  test_lti_get_jwt_claim_mapping()
  test_lti_build_standard_message_institution_name_set()
  test_lti_build_standard_message_institution_name_not_set()
  test_lti_verify_jwt_signature()
  test_lti_verify_jwt_signature_jwk()
  test_lti_verify_jwt_signature_with_lti2()
  test_lti_verify_jwt_signature_no_consumer_key()
  test_lti_verify_jwt_signature_no_public_key()
  test_lti_convert_content_items()
  test_lti_sign_jwt()
  test_lti_convert_from_jwt()
  test_lti_get_permitted_service_scopes()
  test_get_tool_type_config()
  test_lti_new_access_token()
  test_lti_build_login_request()
  test_lti_get_launch_data_default_organizationid_unset_usehost()
  test_lti_get_launch_data_default_organizationid_set_usehost()
  test_lti_get_launch_data_default_organizationid_set_usesiteid()
  test_lti_get_launch_data_default_organizationid_orgid_override()
  create_type()
  create_instance()


Class: mod_lti_locallib_testcase  - X-Ref

Local library tests

test_split_custom_parameters()   X-Ref
No description

disabled_test_sign_parameters()   X-Ref
This test has been disabled because the test-tool is
being moved and probably it won't work anymore for this.
We should be testing here local stuff only and leave
outside-checks to the conformance tests. MDL-30347


disabled_test_parse_grade_replace_message()   X-Ref
This test has been disabled because, since its creation,
the sourceId generation has changed and surely this is outdated.
Some day these should be replaced by proper tests, but until then
conformance tests say this is working. MDL-30347


test_lti_ensure_url_is_https()   X-Ref
No description

test_lti_get_url_thumbprint()   X-Ref
Test lti_get_url_thumbprint against various URLs


test_lti_buid_request_resource_link_id()   X-Ref
No description

test_lti_build_request_description()   X-Ref
Test lti_build_request's resource_link_description and ensure
that the newlines in the description are correct.


test_lti_prepare_type_for_save_forcessl()   X-Ref
Tests lti_prepare_type_for_save's handling of the "Force SSL" configuration.


test_lti_load_type_from_cartridge()   X-Ref
Tests lti_load_type_from_cartridge and lti_load_type_if_cartridge


test_lti_load_tool_from_cartridge()   X-Ref
Tests lti_load_tool_from_cartridge and lti_load_tool_if_cartridge


test_lti_build_content_item_selection_request()   X-Ref
Tests for lti_build_content_item_selection_request().


test_lti_build_content_item_selection_request_invalid_tooltype()   X-Ref
Test for lti_build_content_item_selection_request() with nonexistent tool type ID parameter.


test_lti_build_content_item_selection_request_invalid_mediatypes()   X-Ref
Test for lti_build_content_item_selection_request() with invalid media types parameter.


test_lti_build_content_item_selection_request_invalid_presentationtargets()   X-Ref
Test for lti_build_content_item_selection_request() with invalid presentation targets parameter.


lti_get_best_tool_by_url_provider()   X-Ref
Provider for test_lti_get_best_tool_by_url.

return: array of [urlToTest, expectedTool, allTools]

test_lti_get_best_tool_by_url($url, $expected, $tools)   X-Ref
Test lti_get_best_tool_by_url.

param: string $url The URL to test.
param: object $expected The expected tool matching the URL.
param: array $tools The pool of tools to match the URL with.

test_lti_get_jwt_message_type_mapping()   X-Ref
Test lti_get_jwt_message_type_mapping().


test_lti_get_jwt_claim_mapping()   X-Ref
Test lti_get_jwt_claim_mapping()


test_lti_build_standard_message_institution_name_set()   X-Ref
Test lti_build_standard_message().


test_lti_build_standard_message_institution_name_not_set()   X-Ref
Test lti_build_standard_message().


test_lti_verify_jwt_signature()   X-Ref
Test lti_verify_jwt_signature().


test_lti_verify_jwt_signature_jwk()   X-Ref
Test lti_verify_jwt_signature_jwk().


test_lti_verify_jwt_signature_with_lti2()   X-Ref
Test lti_verify_jwt_signature().


test_lti_verify_jwt_signature_no_consumer_key()   X-Ref
Test lti_verify_jwt_signature().


test_lti_verify_jwt_signature_no_public_key()   X-Ref
Test lti_verify_jwt_signature().


test_lti_convert_content_items()   X-Ref
Test lti_convert_content_items().


test_lti_sign_jwt()   X-Ref
Test lti_sign_jwt().


test_lti_convert_from_jwt()   X-Ref
Test lti_convert_from_jwt()


test_lti_get_permitted_service_scopes()   X-Ref
Test lti_get_permitted_service_scopes().


test_get_tool_type_config()   X-Ref
Test get_tool_type_config().


test_lti_new_access_token()   X-Ref
Test lti_new_access_token().


test_lti_build_login_request()   X-Ref
Test lti_build_login_request().


test_lti_get_launch_data_default_organizationid_unset_usehost()   X-Ref
Test default orgid is host if not specified in config (tool installed in earlier version of Moodle).


test_lti_get_launch_data_default_organizationid_set_usehost()   X-Ref
Test default org id is set to host when config is usehost.


test_lti_get_launch_data_default_organizationid_set_usesiteid()   X-Ref
Test default org id is set to site id when config is usesiteid.


test_lti_get_launch_data_default_organizationid_orgid_override()   X-Ref
Test orgid can be overridden in which case default is ignored.


create_type(object $config)   X-Ref
Create an LTI Tool.

param: object $config tool config.
return: object tool.

create_instance(object $type, object $course)   X-Ref
Create an LTI Instance for the tool in a given course.

param: object $type tool for which an instance should be added.
param: object $course course where the instance should be added.
return: object instance.