35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
<?php
|
|
namespace nur\b\date;
|
|
|
|
use nur\t\TestCase;
|
|
|
|
class HourTest extends TestCase {
|
|
function test__toString() {
|
|
self::assertSame("0h00", strval(new Hour(0)));
|
|
self::assertSame("0h56", strval(new Hour(56)));
|
|
self::assertSame("2h00", strval(new Hour(120)));
|
|
self::assertSame("23h59", strval(new Hour(1439)));
|
|
self::assertSame("24h00", strval(new Hour(1440)));
|
|
self::assertSame("0h01", strval(new Hour(1441)));
|
|
}
|
|
|
|
function testFormat() {
|
|
self::assertSame("0h00", (new Hour(0))->format());
|
|
self::assertSame("0h56", (new Hour(56))->format());
|
|
self::assertSame("2h00", (new Hour(120))->format());
|
|
self::assertSame("23h59", (new Hour(1439))->format());
|
|
self::assertSame("24h00", (new Hour(1440))->format());
|
|
self::assertSame("0h01", (new Hour(1441))->format());
|
|
}
|
|
|
|
function testStep() {
|
|
$h = new class extends Hour {
|
|
const STEP = 5;
|
|
};
|
|
$h = $h->newu(10); self::assertSame("0h10", strval($h));
|
|
$h = $h->newu(12); self::assertSame("0h10", strval($h));
|
|
$h = $h->newu(15); self::assertSame("0h15", strval($h));
|
|
$h = $h->newu(17); self::assertSame("0h15", strval($h));
|
|
}
|
|
}
|