server/src/tests/Libraries/UtilsTest.php
changeset 152 dd6b3adde73b
parent 20 a9b98b16b053
child 261 02e2396bcbbc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/server/src/tests/Libraries/UtilsTest.php	Wed Apr 13 13:38:40 2016 +0200
@@ -0,0 +1,34 @@
+<?php
+
+use CorpusParole\Libraries\Utils;
+
+class UtilsTest extends TestCase {
+    function __construct(string $name = null) {
+        parent::__construct($name);
+    }
+
+    public function setup() {
+    }
+
+    public function tearDown() {
+    }
+
+    public function testDateIntervalToMillis() {
+        $di = new \DateInterval("P1Y1M1DT1H1M1S");
+
+        $ms = Utils::dateIntervalToMillis($di);
+
+        $this->assertEquals(34277461000, $ms, "duration must be 3427746100");
+    }
+
+    public function testiso8601IntervalToMillis() {
+        $ms = Utils::iso8601IntervalToMillis("P1Y1M1DT1H1M1S");
+        $this->assertEquals(34277461000, $ms, "duration must be 3427746100");
+    }
+
+    public function testiso8601IntervalToMillisNull() {
+        $ms = Utils::iso8601IntervalToMillis(null);
+        $this->assertNull($ms, "duration must be null");
+    }
+
+}