mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-45765 Calendar import: Fix undefined variable in cron when updating calendar subscriptions
This commit is contained in:
parent
5fd0df97c5
commit
b8ad1728d8
@ -3201,10 +3201,10 @@ function calendar_cron() {
|
||||
mtrace("Updating calendar subscription {$sub->name} in course {$sub->courseid}");
|
||||
try {
|
||||
$log = calendar_update_subscription_events($sub->id);
|
||||
mtrace(trim(strip_tags($log)));
|
||||
} catch (moodle_exception $ex) {
|
||||
|
||||
mtrace('Error updating calendar subscription: ' . $ex->getMessage());
|
||||
}
|
||||
mtrace(trim(strip_tags($log)));
|
||||
}
|
||||
|
||||
mtrace('Finished updating calendar subscriptions.');
|
||||
|
@ -35,9 +35,11 @@ require_once($CFG->dirroot . '/calendar/lib.php');
|
||||
*/
|
||||
class core_calendar_lib_testcase extends advanced_testcase {
|
||||
|
||||
public function test_calendar_get_course_cached() {
|
||||
protected function setUp() {
|
||||
$this->resetAfterTest(true);
|
||||
}
|
||||
|
||||
public function test_calendar_get_course_cached() {
|
||||
// Setup some test courses.
|
||||
$course1 = $this->getDataGenerator()->create_course();
|
||||
$course2 = $this->getDataGenerator()->create_course();
|
||||
@ -68,4 +70,50 @@ class core_calendar_lib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($course3->shortname, $cachedcourse3->shortname);
|
||||
$this->assertEquals($course3->fullname, $cachedcourse3->fullname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test calendar cron with a working subscription URL.
|
||||
*/
|
||||
public function test_calendar_cron_working_url() {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/lib/cronlib.php');
|
||||
|
||||
// Moodle ICal URL (moodle.org events).
|
||||
$presetwhat = 'all';
|
||||
$presettime = 'recentupcoming';
|
||||
$userid = 1;
|
||||
$authtoken = 'a8bcfee2fb868a05357f650bd65dc0699b026524';
|
||||
$subscriptionurl = 'https://moodle.org/calendar/export_execute.php'
|
||||
. '?preset_what='.$presetwhat.'&preset_time='.$presettime.'&userid='.$userid.'&authtoken='.$authtoken;
|
||||
|
||||
$subscription = new stdClass();
|
||||
$subscription->eventtype = 'site';
|
||||
$subscription->name = 'test';
|
||||
$subscription->url = $subscriptionurl;
|
||||
$subscription->pollinterval = 86400;
|
||||
$subscription->lastupdated = 0;
|
||||
calendar_add_subscription($subscription);
|
||||
|
||||
$this->expectOutputRegex('/Events imported: .* Events updated:/');
|
||||
calendar_cron();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test calendar cron with a broken subscription URL.
|
||||
*/
|
||||
public function test_calendar_cron_broken_url() {
|
||||
global $CFG;
|
||||
require_once($CFG->dirroot . '/lib/cronlib.php');
|
||||
|
||||
$subscription = new stdClass();
|
||||
$subscription->eventtype = 'site';
|
||||
$subscription->name = 'test';
|
||||
$subscription->url = 'brokenurl';
|
||||
$subscription->pollinterval = 86400;
|
||||
$subscription->lastupdated = 0;
|
||||
calendar_add_subscription($subscription);
|
||||
|
||||
$this->expectOutputRegex('/Error updating calendar subscription: The given iCal URL is invalid/');
|
||||
calendar_cron();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user