See Release Notes
Long Term Support Release
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 * Tests for langimport events. 19 * 20 * @package tool_langimport 21 * @copyright 2014 Dan Poltawski 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. 23 */ 24 25 defined('MOODLE_INTERNAL') || die(); 26 27 /** 28 * Test class for langimport events. 29 * 30 * @package tool_langimport 31 * @copyright 2014 Dan Poltawski 32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later. 33 */ 34 class tool_langimport_events_testcase extends advanced_testcase { 35 36 /** 37 * Setup testcase. 38 */ 39 public function setUp() { 40 $this->setAdminUser(); 41 $this->resetAfterTest(); 42 } 43 44 public function test_langpack_updated() { 45 global $CFG; 46 47 $event = \tool_langimport\event\langpack_updated::event_with_langcode($CFG->lang); 48 49 // Trigger and capture the event. 50 $sink = $this->redirectEvents(); 51 $event->trigger(); 52 $events = $sink->get_events(); 53 $event = reset($events); 54 55 $this->assertInstanceOf('\tool_langimport\event\langpack_updated', $event); 56 $this->assertEquals(context_system::instance(), $event->get_context()); 57 } 58 59 /** 60 * @expectedException coding_exception 61 * @expectedExceptionMessage The 'langcode' value must be set to a valid language code 62 */ 63 public function test_langpack_updated_validation() { 64 65 \tool_langimport\event\langpack_updated::event_with_langcode('broken langcode'); 66 } 67 68 public function test_langpack_installed() { 69 $event = \tool_langimport\event\langpack_imported::event_with_langcode('fr'); 70 71 // Trigger and capture the event. 72 $sink = $this->redirectEvents(); 73 $event->trigger(); 74 $events = $sink->get_events(); 75 $event = reset($events); 76 77 $this->assertInstanceOf('\tool_langimport\event\langpack_imported', $event); 78 $this->assertEquals(context_system::instance(), $event->get_context()); 79 } 80 81 /** 82 * @expectedException coding_exception 83 * @expectedExceptionMessage The 'langcode' value must be set to a valid language code 84 */ 85 public function test_langpack_installed_validation() { 86 87 \tool_langimport\event\langpack_imported::event_with_langcode('broken langcode'); 88 } 89 90 public function test_langpack_removed() { 91 $event = \tool_langimport\event\langpack_removed::event_with_langcode('fr'); 92 93 // Trigger and capture the event. 94 $sink = $this->redirectEvents(); 95 $event->trigger(); 96 $events = $sink->get_events(); 97 $event = reset($events); 98 99 $this->assertInstanceOf('\tool_langimport\event\langpack_removed', $event); 100 $this->assertEquals(context_system::instance(), $event->get_context()); 101 } 102 103 /** 104 * @expectedException coding_exception 105 * @expectedExceptionMessage The 'langcode' value must be set to a valid language code 106 */ 107 public function test_langpack_removed_validation() { 108 109 \tool_langimport\event\langpack_removed::event_with_langcode('broken langcode'); 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body