server/src/tests/libraries/UtilsTest.php
changeset 152 dd6b3adde73b
parent 151 95dfb40ff3d2
child 153 338bcc78d431
equal deleted inserted replaced
151:95dfb40ff3d2 152:dd6b3adde73b
     1 <?php
       
     2 
       
     3 use CorpusParole\Libraries\Utils;
       
     4 
       
     5 class UtilsTest extends TestCase {
       
     6     function __construct(string $name = null) {
       
     7         parent::__construct($name);
       
     8     }
       
     9 
       
    10     public function setup() {
       
    11     }
       
    12 
       
    13     public function tearDown() {
       
    14     }
       
    15 
       
    16     public function testDateIntervalToMillis() {
       
    17         $di = new \DateInterval("P1Y1M1DT1H1M1S");
       
    18 
       
    19         $ms = Utils::dateIntervalToMillis($di);
       
    20 
       
    21         $this->assertEquals(34277461000, $ms, "duration must be 3427746100");
       
    22     }
       
    23 
       
    24     public function testiso8601IntervalToMillis() {
       
    25         $ms = Utils::iso8601IntervalToMillis("P1Y1M1DT1H1M1S");
       
    26         $this->assertEquals(34277461000, $ms, "duration must be 3427746100");
       
    27     }
       
    28 
       
    29     public function testiso8601IntervalToMillisNull() {
       
    30         $ms = Utils::iso8601IntervalToMillis(null);
       
    31         $this->assertNull($ms, "duration must be null");
       
    32     }
       
    33 
       
    34 }