MDL-80653 h5p: handle content type creation errors in test.

See also same in c7d08f85.
This commit is contained in:
Paul Holden 2024-01-18 18:08:37 +00:00
parent 9d3e70fe06
commit 6435680f5a
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -14,6 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
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 <victor@moodle.com>
* @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 <victor@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \core_h5p\core
*
* @runTestsInSeparateProcesses
*/
@ -70,10 +63,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;