Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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 * The author vault tests. 19 * 20 * @package mod_forum 21 * @copyright 2019 Ryan Wyllie <ryan@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * The author vault tests. 29 * 30 * @package mod_forum 31 * @copyright 2019 Ryan Wyllie <ryan@moodle.com> 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 33 */ 34 class mod_forum_vaults_author_testcase extends advanced_testcase { 35 /** 36 * Test get_from_id. 37 */ 38 public function test_get_from_id() { 39 $this->resetAfterTest(); 40 41 $user = $this->getDataGenerator()->create_user(); 42 $vaultfactory = \mod_forum\local\container::get_vault_factory(); 43 $authorvault = $vaultfactory->get_author_vault(); 44 45 $author = $authorvault->get_from_id($user->id); 46 47 $this->assertEquals($user->id, $author->get_id()); 48 } 49 50 /** 51 * Test get_context_ids_for_author_ids. 52 */ 53 public function test_get_context_ids_for_author_ids() { 54 $this->resetAfterTest(); 55 56 $user1 = $this->getDataGenerator()->create_user(); 57 $user2 = $this->getDataGenerator()->create_user(); 58 $user3 = $this->getDataGenerator()->create_user(); 59 $userid1 = $user1->id; 60 $userid2 = $user2->id; 61 $userid3 = $user3->id; 62 $fakeuserid = $user3->id + 1000; 63 $vaultfactory = \mod_forum\local\container::get_vault_factory(); 64 $authorvault = $vaultfactory->get_author_vault(); 65 $user1context = context_user::instance($user1->id); 66 $user2context = context_user::instance($user2->id); 67 $user3context = context_user::instance($user3->id); 68 $user1contextid = $user1context->id; 69 $user2contextid = $user2context->id; 70 $user3contextid = $user3context->id; 71 $fakeusercontextid = null; 72 $userids = [$userid1, $userid2, $userid3, $fakeuserid]; 73 74 $expected = [ 75 $userid1 => $user1contextid, 76 $userid2 => $user2contextid, 77 $userid3 => $user3contextid, 78 $fakeuserid => $fakeusercontextid 79 ]; 80 81 $this->assertEquals($expected, $authorvault->get_context_ids_for_author_ids($userids)); 82 } 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body