43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Chatbot;
|
|
|
|
use App\Chatbot\TravelPeriods;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\Component\Clock\MockClock;
|
|
|
|
class TravelPeriodsTest extends TestCase
|
|
{
|
|
private TravelPeriods $periods;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->periods = new TravelPeriods([
|
|
['label' => 'Herbst', 'from' => '2026-09-01', 'to' => '2026-10-07'],
|
|
['label' => 'Silvester', 'from' => '2026-12-26', 'to' => '2027-01-03'],
|
|
['label' => '1 Januarwoche', 'from' => '2027-01-02', 'to' => '2027-01-09'],
|
|
], new MockClock('2026-10-08 10:00:00'));
|
|
}
|
|
|
|
public function testFindsACurrentPeriodByLabelIgnoringCase(): void
|
|
{
|
|
$range = $this->periods->find(' silvester ');
|
|
|
|
self::assertSame('2026-12-26', $range['from']->format('Y-m-d'));
|
|
self::assertSame('2027-01-03', $range['to']->format('Y-m-d'));
|
|
}
|
|
|
|
public function testAPeriodWhoseEndHasPassedIsNoLongerOffered(): void
|
|
{
|
|
self::assertNull($this->periods->find('Herbst'));
|
|
self::assertSame(['Silvester', '1 Januarwoche'], $this->periods->labels());
|
|
}
|
|
|
|
public function testAnUnknownLabelIsNull(): void
|
|
{
|
|
self::assertNull($this->periods->find('Pfingsten'));
|
|
}
|
|
}
|