summaryrefslogtreecommitdiff
path: root/tests/Unit/Helpers/Schedule/CalculatesTimeTest.php
blob: 8f0123e92e111aeb45d8044d3bc44f368eac9bf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php

namespace Engelsystem\Test\Unit\Helpers\Schedule;

use Engelsystem\Helpers\Schedule\CalculatesTime;
use Engelsystem\Test\Unit\TestCase;

class CalculatesTimeTest extends TestCase
{
    /**
     * @covers \Engelsystem\Helpers\Schedule\CalculatesTime::secondsFromTime
     */
    public function testSecondsFromTime()
    {
        $calc = new class {
            use CalculatesTime;

            /**
             * @param string $time
             * @return int
             */
            public function calc(string $time): int
            {
                return $this->secondsFromTime($time);
            }
        };

        $this->assertEquals(0, $calc->calc('0:00'));
        $this->assertEquals(60, $calc->calc('0:01'));
        $this->assertEquals(60 * 60, $calc->calc('01:00'));
        $this->assertEquals(60 * 60 * 10 + 60 * 11, $calc->calc('10:11'));
    }
}