Differences Between: [Versions 39 and 310]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Unit tests for the task that fetch the latest version of H5P content types. 19 * 20 * @package core 21 * @copyright 2019 Victor Deniz <victor@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 use core_h5p\local\library\autoloader; 26 use core_h5p\h5p_test_factory; 27 28 defined('MOODLE_INTERNAL') || die(); 29 30 /** 31 * Class containing unit tests for the task that fetch the latest version of H5P content types. 32 * 33 * @package core 34 * @copyright 2019 Victor Deniz <victor@moodle.com> 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 * 37 * @runTestsInSeparateProcesses 38 */ 39 class h5p_get_content_types_task_testcase extends advanced_testcase { 40 41 protected function setup(): void { 42 global $CFG; 43 parent::setUp(); 44 45 autoloader::register(); 46 47 require_once($CFG->libdir . '/tests/fixtures/testable_core_h5p.php'); 48 } 49 50 /** 51 * Test task execution 52 * 53 * return void 54 */ 55 public function test_task_execution(): void { 56 57 if (!PHPUNIT_LONGTEST) { 58 $this->markTestSkipped('PHPUNIT_LONGTEST is not defined'); 59 } 60 61 $this->resetAfterTest(); 62 63 // Fetch generator. 64 $generator = \testing_util::get_data_generator(); 65 $h5pgenerator = $generator->get_plugin_generator('core_h5p'); 66 67 $factory = new h5p_test_factory(); 68 $core = $factory->get_core(); 69 $core->set_endpoint($this->getExternalTestFileUrl('')); 70 $contenttypespending = ['H5P.Accordion']; 71 72 $h5pgenerator->create_content_types( $contenttypespending, $core); 73 74 // Mock implementation of \core\task\h5p_get_content_types_task::get_core to avoid external systems. 75 $mocktask = $this->getMockBuilder(\core\task\h5p_get_content_types_task::class) 76 ->setMethods(['get_core']) 77 ->getMock(); 78 79 $mocktask->expects($this->any()) 80 ->method('get_core') 81 ->willReturn($core); 82 83 $mocktask->execute(); 84 $this->expectOutputRegex('/1 new content types/'); 85 } 86 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body