. /** * Test for H5P content bank plugin. * * @package contenttype_h5p * @category test * @copyright 2020 Amaia Anabitarte * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Test for H5P content bank plugin. * * @package contenttype_h5p * @category test * @copyright 2020 Amaia Anabitarte * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @coversDefaultClass \contenttype_h5p\content */ class contenttype_h5p_content_plugin_testcase extends advanced_testcase { /** * Tests for uploaded file. * * @covers ::get_file */ public function test_upload_file() { $this->resetAfterTest(); // Create content. $record = new stdClass(); $record->name = 'Test content'; $record->configdata = ''; $contenttype = new \contenttype_h5p\contenttype(context_system::instance()); $content = $contenttype->create_content($record); // Create a dummy file. $filename = 'content.h5p'; $dummy = [ 'contextid' => \context_system::instance()->id, 'component' => 'contentbank', 'filearea' => 'public', 'itemid' => $content->get_id(), 'filepath' => '/', 'filename' => $filename ]; $fs = get_file_storage(); $fs->create_file_from_string($dummy, 'dummy content'); $file = $content->get_file(); $this->assertInstanceOf(\stored_file::class, $file); $this->assertEquals($filename, $file->get_filename()); } }