Issue #11 - Small fixed as suggested by Brendan.

This commit is contained in:
Daniel Thee Roperto
2016-09-12 13:57:33 +10:00
parent 25abb3ae82
commit ee771daecf
9 changed files with 53 additions and 149 deletions

View File

@@ -182,42 +182,6 @@ class outagedb_test extends advanced_testcase {
self::assertSame($activeid, outagedb::get_active($now)->id, 'Wrong active outage picked.');
}
public function test_getallactive() {
$this->resetAfterTest(true);
// Have a consistent time for now (no seconds variation), helps debugging.
$now = time();
self::assertEquals([], outagedb::get_all(), 'Ensure there are no other outages that can affect the test.');
self::assertEquals([], outagedb::get_all_active($now), 'There should be no active outages at this point.');
self::saveoutage($now, 1, 2, 3, 'An outage that starts in the future and is not in warning period.');
self::assertEquals([], outagedb::get_all_active($now), 'No active outages yet.');
self::saveoutage($now, -3, -2, -1, 'An outage that is already in the past.');
self::assertEquals([], outagedb::get_all_active($now), 'No active outages yet.');
$id1 = self::saveoutage($now, -2, 1, 2, 'An outage in warning period.');
self::assertEquals([$id1],
self::createidarray(outagedb::get_all_active($now)), 'Wrong actives data.');
$id2 = self::saveoutage($now, -1, 2, 3, 'Another outage in warning period.');
self::assertEquals([$id1, $id2],
self::createidarray(outagedb::get_all_active($now)), 'Wrong actives data.');
$id3 = self::saveoutage($now, -3, -2, 2, 'An ongoing outage.');
self::assertEquals([$id3, $id1, $id2],
self::createidarray(outagedb::get_all_active($now)), 'Wrong actives data.');
$id4 = self::saveoutage($now, -3, -1, 1, 'Another ongoing outage.');
self::assertEquals([$id3, $id4, $id1, $id2],
self::createidarray(outagedb::get_all_active($now)), 'Wrong actives data.');
$id5 = self::saveoutage($now, -3, -2, 1, 'Yet another ongoing outage.');
self::assertEquals([$id3, $id5, $id4, $id1, $id2],
self::createidarray(outagedb::get_all_active($now)), 'Wrong actives data.');
}
public function test_getallfuture() {
$this->resetAfterTest(true);
@@ -230,12 +194,6 @@ class outagedb_test extends advanced_testcase {
self::saveoutage($now, -3, -2, -1, 'A past outage.');
self::assertEquals([], outagedb::get_all_future($now), 'No future outages yet.');
self::saveoutage($now, -2, 1, 2, 'An outage in warning period.');
self::assertEquals([], outagedb::get_all_future($now), 'No future outages yet.');
self::saveoutage($now, -3, -2, 2, 'An ongoing outage.');
self::assertEquals([], outagedb::get_all_future($now), 'No future outages yet.');
$id1 = self::saveoutage($now, 2, 3, 4, 'A future outage.');
self::assertEquals([$id1],
self::createidarray(outagedb::get_all_future($now)), 'Wrong future data.');
@@ -247,6 +205,26 @@ class outagedb_test extends advanced_testcase {
$id3 = self::saveoutage($now, 1, 3, 5, 'Yet another future outage.');
self::assertEquals([$id3, $id1, $id2],
self::createidarray(outagedb::get_all_future($now)), 'Wrong future data.');
$id4 = self::saveoutage($now, -2, 1, 2, 'An outage in warning period.');
self::assertEquals([$id4, $id3, $id1, $id2],
self::createidarray(outagedb::get_all_future($now)), 'Wrong future data.');
$id5 = self::saveoutage($now, -1, 2, 3, 'Another outage in warning period.');
self::assertEquals([$id4, $id5, $id3, $id1, $id2],
self::createidarray(outagedb::get_all_future($now)), 'Wrong future data.');
$id6 = self::saveoutage($now, -3, -2, 2, 'An ongoing outage.');
self::assertEquals([$id6, $id4, $id5, $id3, $id1, $id2],
self::createidarray(outagedb::get_all_future($now)), 'Wrong future data.');
$id7 = self::saveoutage($now, -3, -1, 1, 'Another ongoing outage.');
self::assertEquals([$id6, $id7, $id4, $id5, $id3, $id1, $id2],
self::createidarray(outagedb::get_all_future($now)), 'Wrong future data.');
$id8 = self::saveoutage($now, -3, -2, 1, 'Yet another ongoing outage.');
self::assertEquals([$id6, $id8, $id7, $id4, $id5, $id3, $id1, $id2],
self::createidarray(outagedb::get_all_future($now)), 'Wrong future data.');
}
public function test_getallpast() {