See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401]
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 namespace mod_forum; 18 19 use mod_forum\local\entities\forum as forum_entity; 20 use mod_forum\local\exporters\forum as forum_exporter; 21 22 /** 23 * The discussion forum tests. 24 * 25 * @package mod_forum 26 * @copyright 2019 Ryan Wyllie <ryan@moodle.com> 27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 28 */ 29 class exporters_forum_test extends \advanced_testcase { 30 /** 31 * Test the export function returns expected values. 32 */ 33 public function test_export() { 34 global $PAGE; 35 $this->resetAfterTest(); 36 37 $renderer = $PAGE->get_renderer('core'); 38 $datagenerator = $this->getDataGenerator(); 39 $user = $datagenerator->create_user(); 40 $course = $datagenerator->create_course(); 41 $forum = $datagenerator->create_module('forum', [ 42 'course' => $course->id, 43 'groupmode' => VISIBLEGROUPS 44 ]); 45 $coursemodule = get_coursemodule_from_instance('forum', $forum->id); 46 $context = \context_module::instance($coursemodule->id); 47 $entityfactory = \mod_forum\local\container::get_entity_factory(); 48 $forum = $entityfactory->get_forum_from_stdClass($forum, $context, $coursemodule, $course); 49 50 $exporter = new forum_exporter($forum, [ 51 'legacydatamapperfactory' => \mod_forum\local\container::get_legacy_data_mapper_factory(), 52 'urlfactory' => \mod_forum\local\container::get_url_factory(), 53 'capabilitymanager' => (\mod_forum\local\container::get_manager_factory())->get_capability_manager($forum), 54 'user' => $user, 55 'currentgroup' => null, 56 'vaultfactory' => \mod_forum\local\container::get_vault_factory() 57 ]); 58 59 $exportedforum = $exporter->export($renderer); 60 61 $this->assertEquals($forum->get_id(), $exportedforum->id); 62 $this->assertEquals(VISIBLEGROUPS, $exportedforum->state['groupmode']); 63 $this->assertEquals(false, $exportedforum->userstate['tracked']); 64 $this->assertEquals(false, $exportedforum->capabilities['viewdiscussions']); 65 $this->assertEquals(false, $exportedforum->capabilities['create']); 66 $this->assertEquals(false, $exportedforum->capabilities['subscribe']); 67 $this->assertNotEquals(null, $exportedforum->urls['create']); 68 $this->assertNotEquals(null, $exportedforum->urls['markasread']); 69 } 70 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body