2 // This file is part of Moodle - http://moodle.org/
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.
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.
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();
19 * Unit tests for the subscription class.
22 * @package tool_monitor
24 * @copyright 2016 Jake Dallimore <jrhdallimore@gmail.com>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 class tool_monitor_subscription_testcase
extends advanced_testcase
{
30 * @var \tool_monitor\subscription $subscription object.
32 private $subscription;
37 public function setUp() {
38 $this->resetAfterTest(true);
40 // Create the mock subscription.
41 $sub = new stdClass();
43 $sub->name
= 'My test rule';
45 $mockbuilder = $this->getMockBuilder('\tool_monitor\subscription');
46 $mockbuilder->setMethods(null);
47 $mockbuilder->setConstructorArgs(array($sub));
48 $this->subscription
= $mockbuilder->getMock();
52 * Test for the magic __isset method.
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
));
61 * Test for the magic __get method.
63 * @expectedException coding_exception
65 public function test_magic_get() {
66 $this->assertEquals(20, $this->subscription
->courseid
);
67 $this->subscription
->ruleid
;