__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core\task;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/calendar/lib.php');
/**
* Class containing unit tests for the calendar cron task.
*
* @package core
* @copyright 2017 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
final class calendar_cron_task_test extends \advanced_testcase {
/**
* Tests set up
*/
protected function setUp(): void {
parent::setUp();
$this->resetAfterTest();
}
/**
* Test calendar cron task with a working subscription URL.
*/
public function test_cron_working_url(): void {
// ICal URL from external test repo.
$subscriptionurl = $this->getExternalTestFileUrl('/ical.ics');
$subscription = new \stdClass();
$subscription->eventtype = 'site';
$subscription->name = 'test';
$subscription->url = $subscriptionurl;
$subscription->pollinterval = 86400;
$subscription->lastupdated = 0;
calendar_add_subscription($subscription);
$task = new calendar_cron_task();
ob_start();
$task->execute();
$output = ob_get_clean();
$this->assertStringContainsString('events were imported', $output);
$this->assertStringContainsString('events were skipped', $output);
$this->assertStringContainsString('events were updated', $output);
}
/**
* Test calendar cron task with a broken subscription URL.
*/
public function test_cron_broken_url(): void {
$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/');
$task = new calendar_cron_task();
$task->execute();
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| adhoc_task_test.php | File | 34.24 KB | 0777 |
|
| automated_backup_task_test.php | File | 5.84 KB | 0777 |
|
| calendar_cron_task_test.php | File | 2.68 KB | 0777 |
|
| completion_daily_task_test.php | File | 5.04 KB | 0777 |
|
| database_logger_test.php | File | 20.01 KB | 0777 |
|
| file_temp_cleanup_task_test.php | File | 6.77 KB | 0777 |
|
| h5p_get_content_types_task_test.php | File | 2.45 KB | 0777 |
|
| hide_ended_courses_task_test.php | File | 4.65 KB | 0777 |
|
| logging_test.php | File | 16.88 KB | 0777 |
|
| manager_test.php | File | 14.01 KB | 0777 |
|
| running_test.php | File | 6.45 KB | 0777 |
|
| scheduled_task_test.php | File | 43.7 KB | 0777 |
|
| send_login_notifications_test.php | File | 11.1 KB | 0777 |
|
| show_started_courses_task_test.php | File | 4.55 KB | 0777 |
|
| stored_progress_bar_cleanup_task_test.php | File | 2.16 KB | 0777 |
|