From 88c5228e61f9784618813985facafd027fde9fd0 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Tue, 7 Sep 2021 17:04:52 +0200 Subject: [PATCH 1/3] MDL-71970 h5plib_v124: Add namespace to H5P core library The joubel/core is a third-party library. A namespace has been added to avoid collision with other plugins using it (such as mod_hvp). That way, they will be able to have a different version without side effects. --- .../joubel/core/h5p-default-storage.class.php | 15 ++++++++------- .../v124/joubel/core/h5p-development.class.php | 2 ++ .../v124/joubel/core/h5p-event-base.class.php | 2 ++ .../joubel/core/h5p-file-storage.interface.php | 2 ++ .../v124/joubel/core/h5p-metadata.class.php | 3 +++ h5p/h5plib/v124/joubel/core/h5p.classes.php | 9 +++++++-- h5p/h5plib/v124/joubel/core/readme_moodle.txt | 12 ++++++++++-- 7 files changed, 34 insertions(+), 11 deletions(-) diff --git a/h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php b/h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php index c58e2fe3908..4028bfc04fa 100644 --- a/h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php +++ b/h5p/h5plib/v124/joubel/core/h5p-default-storage.class.php @@ -1,5 +1,6 @@ path . '/libraries/' . \H5PCore::libraryToString($library, TRUE); + $dest = $this->path . '/libraries/' . H5PCore::libraryToString($library, TRUE); // Make sure destination dir doesn't exist - \H5PCore::deleteFileTree($dest); + H5PCore::deleteFileTree($dest); // Move library folder self::copyFileTree($library['uploadDirectory'], $dest); @@ -60,7 +61,7 @@ class H5PDefaultStorage implements \H5PFileStorage { $dest = "{$this->path}/content/{$content['id']}"; // Remove any old content - \H5PCore::deleteFileTree($dest); + H5PCore::deleteFileTree($dest); self::copyFileTree($source, $dest); } @@ -72,7 +73,7 @@ class H5PDefaultStorage implements \H5PFileStorage { * Content properties */ public function deleteContent($content) { - \H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}"); + H5PCore::deleteFileTree("{$this->path}/content/{$content['id']}"); } /** @@ -133,7 +134,7 @@ class H5PDefaultStorage implements \H5PFileStorage { * Folder that library resides in */ public function exportLibrary($library, $target, $developmentPath=NULL) { - $folder = \H5PCore::libraryToString($library, TRUE); + $folder = H5PCore::libraryToString($library, TRUE); $srcPath = ($developmentPath === NULL ? "/libraries/{$folder}" : $developmentPath); self::copyFileTree("{$this->path}{$srcPath}", "{$target}/{$folder}"); } diff --git a/h5p/h5plib/v124/joubel/core/h5p-development.class.php b/h5p/h5plib/v124/joubel/core/h5p-development.class.php index cae5433c044..4c7fc1f4c7e 100644 --- a/h5p/h5plib/v124/joubel/core/h5p-development.class.php +++ b/h5p/h5plib/v124/joubel/core/h5p-development.class.php @@ -1,5 +1,7 @@ h5pF = $H5PFramework; - $this->fs = ($path instanceof \H5PFileStorage ? $path : new \H5PDefaultStorage($path)); + $this->fs = ($path instanceof H5PFileStorage ? $path : new H5PDefaultStorage($path)); $this->url = $url; $this->exportEnabled = $export; diff --git a/h5p/h5plib/v124/joubel/core/readme_moodle.txt b/h5p/h5plib/v124/joubel/core/readme_moodle.txt index b2226619f34..c9c8a2037cd 100644 --- a/h5p/h5plib/v124/joubel/core/readme_moodle.txt +++ b/h5p/h5plib/v124/joubel/core/readme_moodle.txt @@ -19,13 +19,13 @@ Downloaded version: 1.24.2 release Changes: 1. In order to allow the dependency path to be overridden by child H5PCore classes, a couple of minor changes have been added to the h5p.classes.php file: - - Into the getDependenciesFiles method, the line 2435: + - Into the getDependenciesFiles method, the line 2440: $dependency['path'] = 'libraries/' . H5PCore::libraryToString($dependency, TRUE); has been changed to: $dependency['path'] = $this->getDependencyPath($dependency); - - The method getDependencyPath has been added (line 2455). It might be rewritten by child classes. + - The method getDependencyPath has been added (line 2466). It might be rewritten by child classes. A PR has been sent to the H5P library with these changes: https://github.com/h5p/h5p-php-library/compare/master...andrewnicols:libraryPathSubclass Hopefully, when upgrading, these patch won't be needed because it will be included in the H5P library by default. @@ -74,3 +74,11 @@ with the previous patched and minified JQuery version. * * @member */ + + +4. Add namespace to this library to avoid collision. It means: + +- Add the "namespace Moodle;" line at the top of all the h5p*.php files in the root folder. +- Replace \H5Pxxx uses to H5Pxxx (for instance, in h5p-default-storage.class.php there are several references to \H5PCore that +must be replaced with H5PCore). +- Add "use ZipArchive;" in h5p.classes.h5p (check that it's still used before replacing it when upgrading the library). From 79aa88fddd6c80c280fbb65ccb5e8945e9fa1dfa Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Tue, 7 Sep 2021 17:09:16 +0200 Subject: [PATCH 2/3] MDL-71970 h5plib_v124: Add namespace to H5P editor library The joubel/editor is a third-party library. A namespace has been added to avoid collision with other plugins using it (such as mod_hvp). That way, they will be able to have a different version without side effects. --- h5p/h5plib/v124/joubel/editor/h5peditor-ajax.class.php | 6 ++++-- .../v124/joubel/editor/h5peditor-ajax.interface.php | 1 + h5p/h5plib/v124/joubel/editor/h5peditor-file.class.php | 3 +++ .../v124/joubel/editor/h5peditor-storage.interface.php | 2 ++ h5p/h5plib/v124/joubel/editor/h5peditor.class.php | 10 +++++++--- h5p/h5plib/v124/joubel/editor/readme_moodle.txt | 9 ++++++++- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/h5p/h5plib/v124/joubel/editor/h5peditor-ajax.class.php b/h5p/h5plib/v124/joubel/editor/h5peditor-ajax.class.php index 51ba355dc97..536399287b0 100644 --- a/h5p/h5plib/v124/joubel/editor/h5peditor-ajax.class.php +++ b/h5p/h5plib/v124/joubel/editor/h5peditor-ajax.class.php @@ -1,5 +1,7 @@ editor->ajaxInterface->validateEditorToken($token); if (!$isValidToken) { - \H5PCore::ajaxError( + H5PCore::ajaxError( $this->core->h5pF->t('Invalid security token.'), 'INVALID_TOKEN' ); diff --git a/h5p/h5plib/v124/joubel/editor/h5peditor-ajax.interface.php b/h5p/h5plib/v124/joubel/editor/h5peditor-ajax.interface.php index d45b2b1bea1..89d42634a92 100644 --- a/h5p/h5plib/v124/joubel/editor/h5peditor-ajax.interface.php +++ b/h5p/h5plib/v124/joubel/editor/h5peditor-ajax.interface.php @@ -1,5 +1,6 @@ Date: Tue, 7 Sep 2021 17:15:55 +0200 Subject: [PATCH 3/3] MDL-71970 h5plib_v124: Replace references to new Moodle\H5Pxxx namespace The joubel/core and joubel/editor libraries have been moved to Moodle namespace. This commit adds the new namespace to the places where these classes are used. Besides, a couple of minor changes have been done to replace the _test.php classname and remove some unnecessary defined('MOODLE_INTERNAL'). --- .../contenttype/h5p/classes/contenttype.php | 2 +- .../contenttype/h5p/classes/form/editor.php | 2 +- h5p/ajax.php | 2 ++ h5p/classes/api.php | 5 ++-- h5p/classes/core.php | 15 ++++++----- h5p/classes/editor.php | 4 +-- h5p/classes/editor_ajax.php | 2 +- h5p/classes/editor_framework.php | 2 +- h5p/classes/factory.php | 20 +++++++------- h5p/classes/file_storage.php | 12 +++++---- h5p/classes/framework.php | 18 ++++++------- h5p/classes/local/library/handler.php | 27 ++++++++++--------- h5p/tests/editor_ajax_test.php | 6 ++--- h5p/tests/editor_test.php | 7 ++--- h5p/tests/framework_test.php | 20 +++++++------- 15 files changed, 76 insertions(+), 68 deletions(-) diff --git a/contentbank/contenttype/h5p/classes/contenttype.php b/contentbank/contenttype/h5p/classes/contenttype.php index eda31d90a2f..2c82110d901 100644 --- a/contentbank/contenttype/h5p/classes/contenttype.php +++ b/contentbank/contenttype/h5p/classes/contenttype.php @@ -29,7 +29,7 @@ use stdClass; use core_h5p\editor_ajax; use core_h5p\file_storage; use core_h5p\local\library\autoloader; -use H5PCore; +use Moodle\H5PCore; /** * H5P content bank manager class diff --git a/contentbank/contenttype/h5p/classes/form/editor.php b/contentbank/contenttype/h5p/classes/form/editor.php index 2db471445f0..768a1c2c833 100644 --- a/contentbank/contenttype/h5p/classes/form/editor.php +++ b/contentbank/contenttype/h5p/classes/form/editor.php @@ -129,7 +129,7 @@ class editor extends edit_content { global $DB; // The H5P libraries expect data->id as the H5P content id. - // The method \H5PCore::saveContent throws an error if id is set but empty. + // The method H5PCore::saveContent throws an error if id is set but empty. if (empty($data->id)) { unset($data->id); } else { diff --git a/h5p/ajax.php b/h5p/ajax.php index 915c14538bb..bd0c0faa883 100644 --- a/h5p/ajax.php +++ b/h5p/ajax.php @@ -25,6 +25,8 @@ use core_h5p\factory; use core_h5p\framework; use core_h5p\local\library\autoloader; +use Moodle\H5PCore; +use Moodle\H5PEditorEndpoints; define('AJAX_SCRIPT', true); diff --git a/h5p/classes/api.php b/h5p/classes/api.php index 5eb3ecbef63..88f49ec4249 100644 --- a/h5p/classes/api.php +++ b/h5p/classes/api.php @@ -24,9 +24,8 @@ namespace core_h5p; -defined('MOODLE_INTERNAL') || die(); - use core\lock\lock_config; +use Moodle\H5PCore; /** * Contains API class for the H5P area. @@ -714,7 +713,7 @@ class api { if ($deletefiletree) { // Remove temp content folder. - \H5PCore::deleteFileTree($path); + H5PCore::deleteFileTree($path); } return $isvalid; diff --git a/h5p/classes/core.php b/h5p/classes/core.php index 6b1802421c5..3d45327e363 100644 --- a/h5p/classes/core.php +++ b/h5p/classes/core.php @@ -28,8 +28,9 @@ defined('MOODLE_INTERNAL') || die(); require_once("$CFG->libdir/filelib.php"); -use H5PCore; -use H5PFrameworkInterface; +use Moodle\H5PCore; +use Moodle\H5PFrameworkInterface; +use Moodle\H5PHubEndpoints; use stdClass; use moodle_url; use core_h5p\local\library\autoloader; @@ -41,7 +42,7 @@ use core_h5p\local\library\autoloader; * @copyright 2019 Sara Arjona * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class core extends \H5PCore { +class core extends H5PCore { /** @var array The array containing all the present libraries */ protected $libraries; @@ -50,7 +51,7 @@ class core extends \H5PCore { * Constructor for core_h5p/core. * * @param H5PFrameworkInterface $framework The frameworks implementation of the H5PFrameworkInterface - * @param string|\H5PFileStorage $path The H5P file storage directory or class + * @param string|H5PFileStorage $path The H5P file storage directory or class * @param string $url The URL to the file storage directory * @param string $language The language code. Defaults to english * @param boolean $export Whether export is enabled @@ -213,7 +214,7 @@ class core extends \H5PCore { if ($shoulddownload) { $installed['id'] = $this->fetch_content_type($library); if ($installed['id']) { - $installed['name'] = \H5PCore::libraryToString($library); + $installed['name'] = H5PCore::libraryToString($library); $typesinstalled[] = $installed; } } @@ -292,9 +293,9 @@ class core extends \H5PCore { */ public function get_api_endpoint(?string $library = null, string $endpoint = 'content'): moodle_url { if ($endpoint == 'site') { - $h5purl = \H5PHubEndpoints::createURL(\H5PHubEndpoints::SITES ); + $h5purl = H5PHubEndpoints::createURL(H5PHubEndpoints::SITES ); } else if ($endpoint == 'content') { - $h5purl = \H5PHubEndpoints::createURL(\H5PHubEndpoints::CONTENT_TYPES ) . $library; + $h5purl = H5PHubEndpoints::createURL(H5PHubEndpoints::CONTENT_TYPES ) . $library; } return new moodle_url($h5purl); diff --git a/h5p/classes/editor.php b/h5p/classes/editor.php index f46edc479ac..33df1f6f178 100644 --- a/h5p/classes/editor.php +++ b/h5p/classes/editor.php @@ -26,8 +26,8 @@ namespace core_h5p; use core_h5p\local\library\autoloader; use core_h5p\output\h5peditor as editor_renderer; -use H5PCore; -use H5peditor; +use Moodle\H5PCore; +use Moodle\H5peditor; use stdClass; use coding_exception; use MoodleQuickForm; diff --git a/h5p/classes/editor_ajax.php b/h5p/classes/editor_ajax.php index ec349d787ce..22169c0a7c2 100644 --- a/h5p/classes/editor_ajax.php +++ b/h5p/classes/editor_ajax.php @@ -24,7 +24,7 @@ namespace core_h5p; -use H5PEditorAjaxInterface; +use Moodle\H5PEditorAjaxInterface; use core\dml\table as dml_table; /** diff --git a/h5p/classes/editor_framework.php b/h5p/classes/editor_framework.php index 8835aea06c4..dc4e4216990 100644 --- a/h5p/classes/editor_framework.php +++ b/h5p/classes/editor_framework.php @@ -24,7 +24,7 @@ namespace core_h5p; -use H5peditorStorage; +use Moodle\H5peditorStorage; use stdClass; /** diff --git a/h5p/classes/factory.php b/h5p/classes/factory.php index 9d6908a5625..cc5db1ed15f 100644 --- a/h5p/classes/factory.php +++ b/h5p/classes/factory.php @@ -28,10 +28,10 @@ namespace core_h5p; defined('MOODLE_INTERNAL') || die(); use core_h5p\local\library\autoloader; -use H5PContentValidator as content_validator; -use H5peditor; -use H5PStorage as storage; -use H5PValidator as validator; +use Moodle\H5PContentValidator as content_validator; +use Moodle\H5peditor; +use Moodle\H5PStorage as storage; +use Moodle\H5PValidator as validator; /** * H5P factory class. @@ -122,9 +122,9 @@ class factory { } /** - * Returns an instance of the \H5PStorage class. + * Returns an instance of the H5PStorage class. * - * @return \H5PStorage + * @return \Moodle\H5PStorage */ public function get_storage(): storage { if (null === $this->storage) { @@ -135,9 +135,9 @@ class factory { } /** - * Returns an instance of the \H5PValidator class. + * Returns an instance of the H5PValidator class. * - * @return \H5PValidator + * @return \Moodle\H5PValidator */ public function get_validator(): validator { if (null === $this->validator) { @@ -148,9 +148,9 @@ class factory { } /** - * Returns an instance of the \H5PContentValidator class. + * Returns an instance of the H5PContentValidator class. * - * @return \H5PContentValidator + * @return Moodle\H5PContentValidator */ public function get_content_validator(): content_validator { if (null === $this->content_validator) { diff --git a/h5p/classes/file_storage.php b/h5p/classes/file_storage.php index ba032a42dad..ab7497a12b1 100644 --- a/h5p/classes/file_storage.php +++ b/h5p/classes/file_storage.php @@ -24,8 +24,10 @@ namespace core_h5p; -use H5peditorFile; use stored_file; +use Moodle\H5PCore; +use Moodle\H5peditorFile; +use Moodle\H5PFileStorage; /** * Class to handle storage and export of H5P Content. @@ -34,7 +36,7 @@ use stored_file; * @copyright 2019 Victor Deniz * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class file_storage implements \H5PFileStorage { +class file_storage implements H5PFileStorage { /** The component for H5P. */ public const COMPONENT = 'core_h5p'; @@ -84,7 +86,7 @@ class file_storage implements \H5PFileStorage { 'contextid' => $this->context->id, 'component' => self::COMPONENT, 'filearea' => self::LIBRARY_FILEAREA, - 'filepath' => '/' . \H5PCore::libraryToString($library, true) . '/', + 'filepath' => '/' . H5PCore::libraryToString($library, true) . '/', 'itemid' => $library['libraryId'] ]; @@ -160,7 +162,7 @@ class file_storage implements \H5PFileStorage { * @param string $target Where the library folder will be saved */ public function exportLibrary($library, $target) { - $folder = \H5PCore::libraryToString($library, true); + $folder = H5PCore::libraryToString($library, true); $this->export_file_tree($target . '/' . $folder, $this->context->id, self::LIBRARY_FILEAREA, '/' . $folder . '/', $library['libraryId']); } @@ -507,7 +509,7 @@ class file_storage implements \H5PFileStorage { * @return void */ public function removeContentFile($file, $contentid): void { - // Although the interface defines $contentid as int, object given in \H5peditor::processParameters. + // Although the interface defines $contentid as int, object given in H5peditor::processParameters. if (is_object($contentid)) { $contentid = $contentid->id; } diff --git a/h5p/classes/framework.php b/h5p/classes/framework.php index e0d22dbb2e6..4c1241b83d1 100644 --- a/h5p/classes/framework.php +++ b/h5p/classes/framework.php @@ -24,8 +24,8 @@ namespace core_h5p; -defined('MOODLE_INTERNAL') || die(); - +use Moodle\H5PFrameworkInterface; +use Moodle\H5PCore; /** * Moodle's implementation of the H5P framework interface. * @@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die(); * @copyright 2019 Mihail Geshoski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class framework implements \H5PFrameworkInterface { +class framework implements H5PFrameworkInterface { /** @var string The path to the last uploaded h5p */ private $lastuploadedfolder; @@ -490,7 +490,7 @@ class framework implements \H5PFrameworkInterface { // Extract num from records. foreach ($records as $addon) { - $addons[] = \H5PCore::snakeToCamel($addon); + $addons[] = H5PCore::snakeToCamel($addon); } return $addons; @@ -1198,7 +1198,7 @@ class framework implements \H5PFrameworkInterface { 'embedType' => 'iframe', 'disable' => $data->displayoptions, 'title' => $data->title, - 'slug' => \H5PCore::slugify($data->title) . '-' . $data->id, + 'slug' => H5PCore::slugify($data->title) . '-' . $data->id, 'filtered' => $data->filtered, 'libraryId' => $data->libraryid, 'libraryName' => $data->machinename, @@ -1267,7 +1267,7 @@ class framework implements \H5PFrameworkInterface { $dependencies = array(); foreach ($data as $dependency) { unset($dependency->unidepid); - $dependencies[$dependency->machine_name] = \H5PCore::snakeToCamel($dependency); + $dependencies[$dependency->machine_name] = H5PCore::snakeToCamel($dependency); } return $dependencies; @@ -1278,7 +1278,7 @@ class framework implements \H5PFrameworkInterface { * Implements getOption. * * To avoid updating the cache libraries when using the Hub selector, - * {@link \H5PEditorAjax::isContentTypeCacheUpdated}, the setting content_type_cache_updated_at + * {@see \Moodle\H5PEditorAjax::isContentTypeCacheUpdated}, the setting content_type_cache_updated_at * always return the current time. * * @param string $name Identifier for the setting @@ -1290,7 +1290,7 @@ class framework implements \H5PFrameworkInterface { // For now, the download and the embed displayoptions are disabled by default, so only will be rendered when // defined in the displayoptions DB field. // This check should be removed if they are added as new H5P settings, to let admins to define the default value. - return \H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF; + return \Moodle\H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF; } // To avoid update the libraries cache using the Hub selector. @@ -1541,7 +1541,7 @@ class framework implements \H5PFrameworkInterface { * Check whether a user has permissions to execute an action, such as embed H5P content. * Implements hasPermission. * - * @param \H5PPermission $permission Permission type + * @param H5PPermission $permission Permission type * @param int $id Id need by platform to determine permission * @return boolean true if the user can execute the action defined in $permission; false otherwise */ diff --git a/h5p/classes/local/library/handler.php b/h5p/classes/local/library/handler.php index 3e1ee649d9d..31bbe4c2cca 100644 --- a/h5p/classes/local/library/handler.php +++ b/h5p/classes/local/library/handler.php @@ -161,19 +161,20 @@ abstract class handler { */ protected static function get_class_list(): array { return [ - 'H5PCore' => 'h5p.classes.php', - 'H5PFrameworkInterface' => 'h5p.classes.php', - 'H5PContentValidator' => 'h5p.classes.php', - 'H5PValidator' => 'h5p.classes.php', - 'H5PStorage' => 'h5p.classes.php', - 'H5PDevelopment' => 'h5p-development.class.php', - 'H5PFileStorage' => 'h5p-file-storage.interface.php', - 'H5PMetadata' => 'h5p-metadata.class.php', - 'H5peditor' => 'h5peditor.class.php', - 'H5peditorStorage' => 'h5peditor-storage.interface.php', - 'H5PEditorAjaxInterface' => 'h5peditor-ajax.interface.php', - 'H5PEditorAjax' => 'h5peditor-ajax.class.php', - 'H5peditorFile' => 'h5peditor-file.class.php', + 'Moodle\H5PCore' => 'h5p.classes.php', + 'Moodle\H5PFrameworkInterface' => 'h5p.classes.php', + 'Moodle\H5PContentValidator' => 'h5p.classes.php', + 'Moodle\H5PValidator' => 'h5p.classes.php', + 'Moodle\H5PStorage' => 'h5p.classes.php', + 'Moodle\H5PDevelopment' => 'h5p-development.class.php', + 'Moodle\H5PFileStorage' => 'h5p-file-storage.interface.php', + 'Moodle\H5PDefaultStorage' => 'h5p-default-storage.class.php', + 'Moodle\H5PMetadata' => 'h5p-metadata.class.php', + 'Moodle\H5peditor' => 'h5peditor.class.php', + 'Moodle\H5peditorStorage' => 'h5peditor-storage.interface.php', + 'Moodle\H5PEditorAjaxInterface' => 'h5peditor-ajax.interface.php', + 'Moodle\H5PEditorAjax' => 'h5peditor-ajax.class.php', + 'Moodle\H5peditorFile' => 'h5peditor-file.class.php', ]; } } diff --git a/h5p/tests/editor_ajax_test.php b/h5p/tests/editor_ajax_test.php index 04ab135033f..f09de5145a8 100644 --- a/h5p/tests/editor_ajax_test.php +++ b/h5p/tests/editor_ajax_test.php @@ -26,7 +26,7 @@ namespace core_h5p; use core_h5p\local\library\autoloader; -use ReflectionMethod; +use Moodle\H5PCore; /** * @@ -38,7 +38,7 @@ use ReflectionMethod; * * @runTestsInSeparateProcesses */ -class editor_ajax_testcase extends \advanced_testcase { +class editor_ajax_test extends \advanced_testcase { /** @var editor_ajax H5P editor ajax instance */ protected $editorajax; @@ -141,7 +141,7 @@ class editor_ajax_testcase extends \advanced_testcase { [$library, $files] = $h5pgenerator->create_library($h5ptempath, $tmplib->id, $datalib['machinename'], $datalib['majorversion'], $datalib['minorversion'], $datalib['translation']); $h5pfilestorage->saveLibrary($library); - $stringlibs[] = \H5PCore::libraryToString($library); + $stringlibs[] = H5PCore::libraryToString($library); } } diff --git a/h5p/tests/editor_test.php b/h5p/tests/editor_test.php index 8145ab51a08..74fe952b91f 100644 --- a/h5p/tests/editor_test.php +++ b/h5p/tests/editor_test.php @@ -31,6 +31,7 @@ use advanced_testcase; use core_h5p\local\library\autoloader; use MoodleQuickForm; use page_requirements_manager; +use Moodle\H5PCore; /** * @@ -42,7 +43,7 @@ use page_requirements_manager; * * @runTestsInSeparateProcesses */ -class editor_testcase extends advanced_testcase { +class editor_test extends advanced_testcase { /** * Form object to be used in test case. @@ -205,8 +206,8 @@ class editor_testcase extends advanced_testcase { $h5pcorepath = autoloader::get_h5p_core_library_url()->out(); - $expectedcss = \H5PCore::$styles; - $expectedjs = \H5PCore::$scripts; + $expectedcss = H5PCore::$styles; + $expectedjs = H5PCore::$scripts; array_walk($expectedcss, function(&$item, $key) use ($h5pcorepath, $cachebuster) { $item = $h5pcorepath . $item. $cachebuster; diff --git a/h5p/tests/framework_test.php b/h5p/tests/framework_test.php index 9e5c4492567..91604f0d38b 100644 --- a/h5p/tests/framework_test.php +++ b/h5p/tests/framework_test.php @@ -26,6 +26,8 @@ namespace core_h5p; use core_collator; +use Moodle\H5PCore; +use Moodle\H5PDisplayOptionBehaviour; /** * @@ -36,7 +38,7 @@ use core_collator; * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @runTestsInSeparateProcesses */ -class framework_testcase extends \advanced_testcase { +class framework_test extends \advanced_testcase { /** @var \core_h5p\framework */ private $framework; @@ -1653,7 +1655,7 @@ class framework_testcase extends \advanced_testcase { 'embedType' => 'iframe', 'disable' => $h5p->displayoptions, 'title' => $mainlibrary->title, - 'slug' => \H5PCore::slugify($mainlibrary->title) . '-' . $h5p->id, + 'slug' => H5PCore::slugify($mainlibrary->title) . '-' . $h5p->id, 'filtered' => $h5p->filtered, 'libraryId' => $mainlibrary->id, 'libraryName' => $mainlibrary->machinename, @@ -1806,13 +1808,13 @@ class framework_testcase extends \advanced_testcase { $this->resetAfterTest(); // Get value for display_option_download. - $value = $this->framework->getOption(\H5PCore::DISPLAY_OPTION_DOWNLOAD); - $expected = \H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF; + $value = $this->framework->getOption(H5PCore::DISPLAY_OPTION_DOWNLOAD); + $expected = H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF; $this->assertEquals($expected, $value); // Get value for display_option_embed using default value (it should be ignored). - $value = $this->framework->getOption(\H5PCore::DISPLAY_OPTION_EMBED, \H5PDisplayOptionBehaviour::NEVER_SHOW); - $expected = \H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF; + $value = $this->framework->getOption(H5PCore::DISPLAY_OPTION_EMBED, H5PDisplayOptionBehaviour::NEVER_SHOW); + $expected = H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF; $this->assertEquals($expected, $value); // Get value for unexisting setting without default. @@ -1842,11 +1844,11 @@ class framework_testcase extends \advanced_testcase { $this->assertEquals($newvalue, $value); // Set value for display_option_download and then get it again. Check it hasn't changed. - $name = \H5PCore::DISPLAY_OPTION_DOWNLOAD; - $newvalue = \H5PDisplayOptionBehaviour::NEVER_SHOW; + $name = H5PCore::DISPLAY_OPTION_DOWNLOAD; + $newvalue = H5PDisplayOptionBehaviour::NEVER_SHOW; $this->framework->setOption($name, $newvalue); $value = $this->framework->getOption($name); - $expected = \H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF; + $expected = H5PDisplayOptionBehaviour::CONTROLLED_BY_AUTHOR_DEFAULT_OFF; $this->assertEquals($expected, $value); }