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.

Class: api_test  - X-Ref

Test class covering the H5P API.

test_delete_library(string $libraryname, int $expectedh5p, int $expectedlibraries,int $expectedcontents, int $expecteddependencies)   X-Ref
Test the behaviour of delete_library().

param: string $libraryname          Machine name of the library to delete.
param: int    $expectedh5p          Total of H5P contents expected after deleting the library.
param: int    $expectedlibraries    Total of H5P libraries expected after deleting the library.
param: int    $expectedcontents     Total of H5P content_libraries expected after deleting the library.
param: int    $expecteddependencies Total of H5P library dependencies expected after deleting the library.

delete_library_provider()   X-Ref
Data provider for test_delete_library().

return: array

test_get_dependent_libraries(string $libraryname, int $expectedvalue)   X-Ref
Test the behaviour of get_dependent_libraries().

param: string $libraryname     Machine name of the library to delete.
param: int    $expectedvalue   Total of H5P required libraries expected.

get_dependent_libraries_provider()   X-Ref
Data provider for test_get_dependent_libraries().

return: array

test_get_library(string $libraryname, bool $emptyexpected)   X-Ref
Test the behaviour of get_library().

param: string $libraryname     Machine name of the library to delete.
param: bool   $emptyexpected   Wether the expected result is empty or not.

get_library_provider()   X-Ref
Data provider for test_get_library().

return: array

test_get_content_from_pluginfile_url()   X-Ref
Test the behaviour of get_content_from_pluginfile_url().


test_create_content_from_pluginfile_url()   X-Ref
Test the behaviour of create_content_from_pluginfile_url().


test_delete_content_from_pluginfile_url()   X-Ref
Test the behaviour of delete_content_from_pluginfile_url().


test_get_export_info_from_context_id()   X-Ref
Test the behaviour of get_export_info_from_context_id().


test_set_library_enabled(string $libraryname, string $action, int $expected)   X-Ref
Test the behaviour of set_library_enabled().

param: string $libraryname Library name to enable/disable.
param: string $action Action to be done with the library. Supported values: enable, disable.
param: int $expected Expected value for the enabled library field. -1 will be passed if the library doesn't exist.

set_library_enabled_provider()   X-Ref
Data provider for test_set_library_enabled().

return: array

test_is_library_enabled(string $libraryname, bool $expected, bool $exception = false,bool $useid = false, bool $uselibraryname = true)   X-Ref
Test the behaviour of is_library_enabled().

param: string $libraryname Library name to check.
param: bool $expected Expected result after calling the method.
param: bool $exception Exception expected or not.
param: bool $useid Whether to use id for calling is_library_enabled method.
param: bool $uselibraryname Whether to use libraryname for calling is_library_enabled method.

is_library_enabled_provider()   X-Ref
Data provider for test_is_library_enabled().

return: array

test_is_valid_package(string $filename, bool $expected, bool $isadmin = false, bool $onlyupdatelibs = false,bool $skipcontent = false)   X-Ref
Test the behaviour of is_valid_package().

param: string $filename The H5P content to validate.
param: bool $expected Expected result after calling the method.
param: bool $isadmin Whether the user calling the method will be admin or not.
param: bool $onlyupdatelibs Whether new libraries can be installed or only the existing ones can be updated.
param: bool $skipcontent Should the content be skipped (so only the libraries will be saved)?

is_valid_package_provider()   X-Ref
Data provider for test_is_valid_package().

return: array