mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-16 21:41:31 +02:00
Added full phpunit coverage for classes in: cli and event
This commit is contained in:
@@ -19,10 +19,6 @@ namespace auth_outage\cli;
|
||||
use core\session\manager;
|
||||
use InvalidArgumentException;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir . '/clilib.php');
|
||||
|
||||
/**
|
||||
* Outage CLI base class.
|
||||
*
|
||||
@@ -48,6 +44,9 @@ abstract class clibase {
|
||||
* @throws cliexception
|
||||
*/
|
||||
public function __construct(array $options = null) {
|
||||
global $CFG;
|
||||
require_once($CFG->libdir . '/clilib.php');
|
||||
|
||||
$this->becomeadmin();
|
||||
|
||||
if (is_null($options)) {
|
||||
|
||||
@@ -27,4 +27,13 @@ use Exception;
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class cliexception extends Exception {
|
||||
/**
|
||||
* cliexception constructor.
|
||||
* @param string $message An explanation of the exception.
|
||||
* @param int $code Exit code to be used.
|
||||
* @param Exception|null $previous Another exception as reference.
|
||||
*/
|
||||
public function __construct($message, $code = 1, Exception $previous = null) {
|
||||
parent::__construct('*ERROR* ' . $message, $code, $previous = null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ namespace auth_outage\cli;
|
||||
use auth_outage\models\outage;
|
||||
use auth_outage\outagedb;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Outage CLI to create outage.
|
||||
*
|
||||
|
||||
@@ -19,8 +19,6 @@ namespace auth_outage\cli;
|
||||
use auth_outage\models\outage;
|
||||
use auth_outage\outagedb;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Outage CLI to finish an outage.
|
||||
*
|
||||
|
||||
@@ -19,8 +19,6 @@ namespace auth_outage\cli;
|
||||
use auth_outage\models\outage;
|
||||
use auth_outage\outagedb;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Outage CLI to wait for an outage to start.
|
||||
*
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
namespace auth_outage\event;
|
||||
|
||||
use core\event\base;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
use moodle_url;
|
||||
|
||||
/**
|
||||
* The auth_outage outage created class.
|
||||
@@ -51,9 +50,9 @@ class outage_created extends base {
|
||||
|
||||
/**
|
||||
* Returns relevant URL, override in subclasses.
|
||||
* @return \moodle_url
|
||||
* @return moodle_url
|
||||
*/
|
||||
public function get_url() {
|
||||
return new \moodle_url('/auth/outage/list.php#auth_outage_id_' . $this->other['id']);
|
||||
return new moodle_url('/auth/outage/list.php#auth_outage_id_' . $this->other['id']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ namespace auth_outage\event;
|
||||
|
||||
use core\event\base;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The auth_outage outage deleted class.
|
||||
*
|
||||
|
||||
@@ -18,8 +18,6 @@ namespace auth_outage\event;
|
||||
|
||||
use core\event\base;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* The auth_outage outage updated class.
|
||||
*
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
namespace auth_outage;
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
|
||||
}
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->dirroot . '/calendar/lib.php');
|
||||
|
||||
@@ -259,7 +257,7 @@ class outagedb {
|
||||
if (is_null($time)) {
|
||||
$time = time();
|
||||
}
|
||||
if (!is_int($time)) {
|
||||
if (!is_int($time) && ($time <= 0)) {
|
||||
throw new InvalidArgumentException('$time must be an int or null.');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user