feat(services): add generator for public holidays in cz

This commit is contained in:
2024-08-07 12:54:55 +02:00
parent ef937530af
commit 24f36c16d0
5 changed files with 155 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\WorkingDays\PublicHolidays\Generator;
use App\Services\WorkingDays\PublicHolidays\Generator\PublicHolidaysCzechGenerator;
use PHPUnit\Framework\TestCase;
class PublicHolidaysCzechGeneratorTest extends TestCase
{
public function testCzechPublicHolidays(): void
{
$czechNWD = new PublicHolidaysCzechGenerator();
// generate non-working days for 2025 and assert the results
$czechNWD = $czechNWD->generatePublicHolidaysForYear(2025);
$this->assertEquals([
new \DateTimeImmutable("2025-01-01"),
new \DateTimeImmutable("2025-04-18"),
new \DateTimeImmutable("2025-04-21"),
new \DateTimeImmutable("2025-05-01"),
new \DateTimeImmutable("2025-05-08"),
new \DateTimeImmutable("2025-07-05"),
new \DateTimeImmutable("2025-07-06"),
new \DateTimeImmutable("2025-09-28"),
new \DateTimeImmutable("2025-10-28"),
new \DateTimeImmutable("2025-11-17"),
new \DateTimeImmutable("2025-12-24"),
new \DateTimeImmutable("2025-12-25"),
new \DateTimeImmutable("2025-12-26"),
], $czechNWD);
}
}

View File

@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace Tests\Unit\Services\WorkingDays;
use App\Services\WorkingDays\PublicHolidays\Generator\PublicHolidaysCzechGenerator;
use App\Services\WorkingDays\PublicHolidays\PublicHolidaysGeneratorFactory;
use Tests\TestCase;
class PublicHolidaysGeneratorFactoryTest extends TestCase
{
public function testPublicHolidaysGeneratorFactoryWillReturnCzechGeneratorForCZ(): void
{
$factory = new PublicHolidaysGeneratorFactory();
$this->assertInstanceOf(PublicHolidaysCzechGenerator::class, $factory->createPublicHolidaysGeneratorForCountry('CZ'));
}
public function testRuntimeExceptionGeneratedForUnknownState(): void
{
$factory = new PublicHolidaysGeneratorFactory();
$this->expectException(\RuntimeException::class);
$factory->createPublicHolidaysGeneratorForCountry('XZ');
}
}