server/src/tests/Libraries/UtilsTest.php
author ymh <ymh.work@gmail.com>
Tue, 20 Mar 2018 15:02:40 +0100
changeset 573 25f3d28f51b2
parent 261 02e2396bcbbc
permissions -rw-r--r--
Added tag 0.0.25 for changeset 190ae1dee68d

<?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");
    }

    public function testiso8601IntervalToMillisDoubleZero() {
        $ms = Utils::iso8601IntervalToMillis("PT47M00S");
        $this->assertEquals(2820000, $ms, "duration must be 2820000");
    }


}