Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [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 defined('MOODLE_INTERNAL') || exit(); 17 18 /** 19 * Unit tests for the subscription class. 20 * @since 3.2.0 21 * 22 * @package tool_monitor 23 * @category test 24 * @copyright 2016 Jake Dallimore <jrhdallimore@gmail.com> 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 class tool_monitor_subscription_testcase extends advanced_testcase { 28 29 /** 30 * @var \tool_monitor\subscription $subscription object. 31 */ 32 private $subscription; 33 34 /** 35 * Test set up. 36 */ 37 public function setUp(): void { 38 $this->resetAfterTest(true); 39 40 // Create the mock subscription. 41 $sub = new stdClass(); 42 $sub->id = 100; 43 $sub->name = 'My test rule'; 44 $sub->courseid = 20; 45 $mockbuilder = $this->getMockBuilder('\tool_monitor\subscription'); 46 $mockbuilder->setMethods(null); 47 $mockbuilder->setConstructorArgs(array($sub)); 48 $this->subscription = $mockbuilder->getMock(); 49 } 50 51 /** 52 * Test for the magic __isset method. 53 */ 54 public function test_magic_isset() { 55 $this->assertEquals(true, isset($this->subscription->name)); 56 $this->assertEquals(true, isset($this->subscription->courseid)); 57 $this->assertEquals(false, isset($this->subscription->ruleid)); 58 } 59 60 /** 61 * Test for the magic __get method. 62 */ 63 public function test_magic_get() { 64 $this->assertEquals(20, $this->subscription->courseid); 65 $this->expectException(coding_exception::class); 66 $this->subscription->ruleid; 67 } 68 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body