feat(services): add public holidays states infra
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Services\WorkingDays\PublicHolidays;
|
||||
|
||||
use App\Services\WorkingDays\PublicHolidays\PublicHolidaysStateDeterminer;
|
||||
use App\Services\WorkingDays\PublicHolidays\Storage\PublicHolidaysStorageInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PublicHolidaysStateDeterminerTest extends TestCase
|
||||
{
|
||||
public function testStorageCalledWhenDeterminatePublicHoliday(): void
|
||||
{
|
||||
$date = new \DateTimeImmutable('2024-01-01');
|
||||
$storage = $this->createMock(PublicHolidaysStorageInterface::class);
|
||||
$storage->expects($this->once())->method('isPublicHoliday')->with('CZ', $date);
|
||||
$determiner = new PublicHolidaysStateDeterminer($storage, 'CZ');
|
||||
$determiner->isPublicHoliday($date);
|
||||
}
|
||||
|
||||
public function testStorageCalledWhenStorePublicHoliday(): void
|
||||
{
|
||||
$date = new \DateTimeImmutable('2024-01-01');
|
||||
$storage = $this->createMock(PublicHolidaysStorageInterface::class);
|
||||
$storage->expects($this->once())->method('storePublicHoliday')->with('CZ', $date);
|
||||
$determiner = new PublicHolidaysStateDeterminer($storage, 'CZ');
|
||||
$determiner->storePublicHoliday($date);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Services\WorkingDays;
|
||||
|
||||
use App\Services\WorkingDays\PublicHolidays\PublicHolidaysStateDeterminer;
|
||||
use App\Services\WorkingDays\PublicHolidays\PublicHolidaysStateFactory;
|
||||
use App\Services\WorkingDays\PublicHolidays\PublicHolidaysStateStorageInterface;
|
||||
use App\Services\WorkingDays\PublicHolidays\Storage\PublicHolidaysStorageInterface;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PublicHolidaysStateFactoryTest extends TestCase
|
||||
{
|
||||
public function testCreateStoreForCountryWillReturnCzechStorageForCZ(): void
|
||||
{
|
||||
$storage = $this->createMock(PublicHolidaysStorageInterface::class);
|
||||
$factory = new PublicHolidaysStateFactory($storage);
|
||||
$store = $factory->createStoreForCountry('CZ');
|
||||
$determiner = $factory->createDeterminerForCountry('CZ');
|
||||
$this->assertInstanceOf(PublicHolidaysStateStorageInterface::class, $store);
|
||||
$this->assertInstanceOf(PublicHolidaysStateDeterminer::class, $determiner);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user