diff --git a/h5p/tests/h5p_core_test.php b/h5p/tests/h5p_core_test.php
index 355be8ca80d..55cf3e5c699 100644
--- a/h5p/tests/h5p_core_test.php
+++ b/h5p/tests/h5p_core_test.php
@@ -14,6 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+namespace core_h5p;
+
+use core_h5p\local\library\autoloader;
+
+use invalid_response_exception;
+
/**
* Testing the H5P core methods.
*
@@ -21,20 +27,7 @@
* @category test
* @copyright 2019 Victor Deniz
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-namespace core_h5p;
-
-use core_h5p\local\library\autoloader;
-
-defined('MOODLE_INTERNAL') || die();
-
-/**
- * Test class covering the H5PFileStorage interface implementation.
- *
- * @package core_h5p
- * @copyright 2019 Victor Deniz
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @covers \core_h5p\core
*
* @runTestsInSeparateProcesses
*/
@@ -67,10 +60,14 @@ class h5p_core_test extends \advanced_testcase {
$this->resetAfterTest(true);
// Get info of latest content types versions.
- $contenttypes = $this->core->get_latest_content_types()->contentTypes;
+ $response = $this->core->get_latest_content_types();
+ if (!empty($response->error)) {
+ throw new invalid_response_exception($response->error);
+ }
+
// We are installing the first content type with tutorial and example fields (or the first one if none has them).
- $librarydata = $contenttypes[0];
- foreach ($contenttypes as $contentype) {
+ $librarydata = $response->contentTypes[0];
+ foreach ($response->contentTypes as $contenttype) {
if (isset($contenttype->tutorial) && isset($contenttype->example)) {
$librarydata = $contenttype;
break;