summaryrefslogtreecommitdiff
path: root/tests/units/Helper/DatetimeHelperTest.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-09-05 23:30:56 -0400
committerFrederic Guillot <fred@kanboard.net>2015-09-05 23:30:56 -0400
commit710f2c7bb046b43ec9878ae795a181101f6d7515 (patch)
treeb62723b6b49c3b6bf2b3ca41a772f552464a9031 /tests/units/Helper/DatetimeHelperTest.php
parent94b38dd94bd819168163003beec8ef693f9d9839 (diff)
Improve unit tests
Diffstat (limited to 'tests/units/Helper/DatetimeHelperTest.php')
-rw-r--r--tests/units/Helper/DatetimeHelperTest.php56
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('&lt;15m', $h->age(0, 30));
+ $this->assertEquals('&lt;30m', $h->age(0, 1000));
+ $this->assertEquals('&lt;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));
+ }
+}