diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-09-05 23:30:56 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-09-05 23:30:56 -0400 |
commit | 710f2c7bb046b43ec9878ae795a181101f6d7515 (patch) | |
tree | b62723b6b49c3b6bf2b3ca41a772f552464a9031 /tests/units/Helper/DatetimeHelperTest.php | |
parent | 94b38dd94bd819168163003beec8ef693f9d9839 (diff) |
Improve unit tests
Diffstat (limited to 'tests/units/Helper/DatetimeHelperTest.php')
-rw-r--r-- | tests/units/Helper/DatetimeHelperTest.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/units/Helper/DatetimeHelperTest.php b/tests/units/Helper/DatetimeHelperTest.php new file mode 100644 index 00000000..d4fc3c3d --- /dev/null +++ b/tests/units/Helper/DatetimeHelperTest.php @@ -0,0 +1,56 @@ +<?php + +require_once __DIR__.'/../Base.php'; + +use Helper\Dt; + +class DatetimeHelperTest extends Base +{ + public function testAge() + { + $h = new Dt($this->container); + + $this->assertEquals('<15m', $h->age(0, 30)); + $this->assertEquals('<30m', $h->age(0, 1000)); + $this->assertEquals('<1h', $h->age(0, 3000)); + $this->assertEquals('~2h', $h->age(0, 2*3600)); + $this->assertEquals('1d', $h->age(0, 30*3600)); + $this->assertEquals('2d', $h->age(0, 65*3600)); + } + + public function testGetDayHours() + { + $h = new Dt($this->container); + + $slots = $h->getDayHours(); + + $this->assertNotEmpty($slots); + $this->assertCount(48, $slots); + $this->assertArrayHasKey('00:00', $slots); + $this->assertArrayHasKey('00:30', $slots); + $this->assertArrayHasKey('01:00', $slots); + $this->assertArrayHasKey('01:30', $slots); + $this->assertArrayHasKey('23:30', $slots); + $this->assertArrayNotHasKey('24:00', $slots); + } + + public function testGetWeekDays() + { + $h = new Dt($this->container); + + $slots = $h->getWeekDays(); + + $this->assertNotEmpty($slots); + $this->assertCount(7, $slots); + $this->assertContains('Monday', $slots); + $this->assertContains('Sunday', $slots); + } + + public function testGetWeekDay() + { + $h = new Dt($this->container); + + $this->assertEquals('Monday', $h->getWeekDay(1)); + $this->assertEquals('Sunday', $h->getWeekDay(7)); + } +} |