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 * File containing the forum module local library function tests. 19 * 20 * @package mod_forum 21 * @category test 22 * @copyright 2018 Shamim Rezaie <shamim@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 namespace mod_forum; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 global $CFG; 30 31 require_once($CFG->dirroot . '/mod/forum/lib.php'); 32 33 /** 34 * Class mod_forum_locallib_testcase. 35 * 36 * @copyright 2018 Shamim Rezaie <shamim@moodle.com> 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class locallib_test extends \advanced_testcase { 40 public function test_forum_update_calendar() { 41 global $DB; 42 43 $this->resetAfterTest(); 44 45 $this->setAdminUser(); 46 47 // Create a course. 48 $course = $this->getDataGenerator()->create_course(); 49 50 // Create a forum activity. 51 $time = time(); 52 $forum = $this->getDataGenerator()->create_module('forum', 53 array( 54 'course' => $course->id, 55 'duedate' => $time 56 ) 57 ); 58 59 // Check that there is now an event in the database. 60 $events = $DB->get_records('event'); 61 $this->assertCount(1, $events); 62 63 // Get the event. 64 $event = reset($events); 65 66 // Confirm the event is correct. 67 $this->assertEquals('forum', $event->modulename); 68 $this->assertEquals($forum->id, $event->instance); 69 $this->assertEquals(CALENDAR_EVENT_TYPE_ACTION, $event->type); 70 $this->assertEquals(FORUM_EVENT_TYPE_DUE, $event->eventtype); 71 $this->assertEquals($time, $event->timestart); 72 $this->assertEquals($time, $event->timesort); 73 } 74 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body