Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.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_get_original_content_from_pluginfile_url()   X-Ref
Test the behaviour of get_original_content_from_pluginfile_url().


test_can_edit_content(string $currentuser, string $fileauthor, string $filecomponent, bool $expected,$filearea = 'unittest')   X-Ref
Test the behaviour of can_edit_content().

param: string $currentuser User who will call the method.
param: string $fileauthor Author of the file to check.
param: string $filecomponent Component of the file to check.
param: bool $expected Expected result after calling the can_edit_content method.
param: string $filearea Area of the file to check.
return: void

can_edit_content_provider()   X-Ref
Data provider for test_can_edit_content().

return: array

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