Differences Between: [Versions 310 and 403] [Versions 39 and 403]
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 * Contains the tests for the course_content_items_exporter class. 19 * 20 * @package core 21 * @subpackage course 22 * @copyright 2020 Jake Dallimore <jrhdallimore@gmail.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 namespace core_course; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use core_course\local\exporters\course_content_items_exporter; 30 use core_course\local\repository\content_item_readonly_repository; 31 32 /** 33 * The tests for the course_content_items_exporter class. 34 * 35 * @copyright 2020 Jake Dallimore <jrhdallimore@gmail.com> 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class exporters_content_items_test extends \advanced_testcase { 39 40 /** 41 * Test confirming the collection of content_items can be exported for a course. 42 */ 43 public function test_export_course_content_items() { 44 $this->resetAfterTest(); 45 global $PAGE; 46 47 $course = $this->getDataGenerator()->create_course(); 48 $user = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher'); 49 $cir = new content_item_readonly_repository(); 50 $contentitems = $cir->find_all_for_course($course, $user); 51 52 $ciexporter = new course_content_items_exporter($contentitems, ['context' => \context_course::instance($course->id)]); 53 $renderer = $PAGE->get_renderer('core'); 54 $exportedcontentitems = $ciexporter->export($renderer); 55 56 $this->assertObjectHasAttribute('content_items', $exportedcontentitems); 57 foreach ($exportedcontentitems->content_items as $key => $dto) { 58 $this->assertObjectHasAttribute('id', $dto); 59 $this->assertObjectHasAttribute('name', $dto); 60 $this->assertObjectHasAttribute('title', $dto); 61 $this->assertObjectHasAttribute('link', $dto); 62 $this->assertObjectHasAttribute('icon', $dto); 63 $this->assertObjectHasAttribute('help', $dto); 64 $this->assertObjectHasAttribute('archetype', $dto); 65 $this->assertObjectHasAttribute('componentname', $dto); 66 } 67 } 68 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body