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/>.
18 * Calendar Ical unit tests
20 * @package core_calendar
21 * @copyright 2013 Ankit Agarwal
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
31 * Unit tests for ical APIs.
33 * @package core_calendar
34 * @copyright 2013 Ankit Agarwal
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 class core_calendar_ical_testcase
extends advanced_testcase
{
43 protected function setUp() {
45 require_once($CFG->dirroot
. '/calendar/lib.php');
48 public function test_calendar_update_subscription() {
49 $this->resetAfterTest(true);
51 $subscription = new stdClass();
52 $subscription->eventtype
= 'site';
53 $subscription->name
= 'test';
54 $id = calendar_add_subscription($subscription);
56 $subscription = new stdClass();
57 $subscription->id
= $id;
58 $subscription->name
= 'awesome';
59 calendar_update_subscription($subscription);
60 $sub = calendar_get_subscription($id);
61 $this->assertEquals($subscription->name
, $sub->name
);
63 $subscription = new stdClass();
64 $subscription->id
= $id;
65 $subscription->name
= 'awesome2';
66 $subscription->pollinterval
= 604800;
67 calendar_update_subscription($subscription);
68 $sub = calendar_get_subscription($id);
69 $this->assertEquals($subscription->name
, $sub->name
);
70 $this->assertEquals($subscription->pollinterval
, $sub->pollinterval
);
72 $subscription = new stdClass();
73 $subscription->name
= 'awesome4';
74 $this->setExpectedException('coding_exception');
75 calendar_update_subscription($subscription);