AzuraCast/tests/Unit/ListenerIntervalTest.php

37 lines
1.2 KiB
PHP

<?php
namespace Unit;
use App\Entity;
use Carbon\CarbonImmutable;
class ListenerIntervalTest extends \Codeception\Test\Unit
{
public function testListenerIntervals(): void
{
$utc = new \DateTimeZone('UTC');
$intervals = [
[
'start' => CarbonImmutable::parse('2019-12-01 00:00:00', $utc)->getTimestamp(),
'end' => CarbonImmutable::parse('2019-12-01 02:05:00', $utc)->getTimestamp(),
],
[
'start' => CarbonImmutable::parse('2019-12-01 00:00:00', $utc)->getTimestamp(),
'end' => CarbonImmutable::parse('2019-12-01 03:00:00', $utc)->getTimestamp(),
],
[
'start' => CarbonImmutable::parse('2019-12-01 05:00:00', $utc)->getTimestamp(),
'end' => CarbonImmutable::parse('2019-12-01 07:05:00', $utc)->getTimestamp(),
],
[
'start' => CarbonImmutable::parse('2019-12-01 05:05:30', $utc)->getTimestamp(),
'end' => CarbonImmutable::parse('2019-12-01 08:00:00', $utc)->getTimestamp(),
],
];
$expected = 6 * 60 * 60;
self::assertEquals($expected, Entity\Listener::getListenerSeconds($intervals));
}
}