Issue #9 - Checking if outage is ongoing or just a warning. Improved hooks, tests and HTML output.

This commit is contained in:
Daniel Thee Roperto
2016-09-06 17:17:26 +10:00
parent be477ee787
commit 583516a3c7
9 changed files with 76 additions and 22 deletions

View File

@@ -28,8 +28,7 @@ use auth_outage\models\outage;
defined('MOODLE_INTERNAL') || die();
class outage_test extends basic_testcase
{
class outage_test extends basic_testcase {
public function test_constructor() {
$outage = new outage();
// Very important, this should never change.
@@ -39,4 +38,38 @@ class outage_test extends basic_testcase
self::assertNull($v);
}
}
public function test_isongoing() {
$now = time();
// In the past.
$outage = new outage([
'starttime' => $now + (-3 * 60 * 60),
'stoptime' => $now + (-2 * 60 * 60),
'warningduration' => 2 * 60 * 60,
'title' => '',
'description' => ''
]);
self::assertFalse($outage->is_ongoing($now));
// In the present (ongoing).
$outage = new outage([
'starttime' => $now + (-1 * 60 * 60),
'stoptime' => $now + (1 * 60 * 60),
'warningduration' => 2 * 60 * 60,
'title' => '',
'description' => ''
]);
self::assertTrue($outage->is_ongoing($now));
// In the future.
$outage = new outage([
'starttime' => $now + (1 * 60 * 60),
'stoptime' => $now + (2 * 60 * 60),
'warningduration' => 2 * 60 * 60,
'title' => '',
'description' => ''
]);
self::assertFalse($outage->is_ongoing($now));
}
}