43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Services\WorkingDays\Utils;
|
|
|
|
use App\Services\WorkingDays\Utils\MultipleWorkingDayDeterminer;
|
|
use App\Services\WorkingDays\WorkingDayDeterminerInterface;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class MultipleWorkingDayDeterminerTest extends TestCase
|
|
{
|
|
public function testAllDeterminersReturnTrueForWorkingDay(): void
|
|
{
|
|
$date = new \DateTimeImmutable('2021-01-01');
|
|
$mock = $this->createMock(WorkingDayDeterminerInterface::class);
|
|
$mock->expects($this->once())->method('isWorkingDay')->with($date)->willReturn(true);
|
|
$mock1 = $this->createMock(WorkingDayDeterminerInterface::class);
|
|
$mock1->expects($this->once())->method('isWorkingDay')->with($date)->willReturn(true);
|
|
$determiner = new MultipleWorkingDayDeterminer([
|
|
$mock,
|
|
$mock1,
|
|
]);
|
|
|
|
$this->assertTrue($determiner->isWorkingDay($date));
|
|
}
|
|
|
|
public function testFirstDeterminerReturnsFalseForWorkingDay(): void
|
|
{
|
|
$date = new \DateTimeImmutable('2021-01-01');
|
|
$mock = $this->createMock(WorkingDayDeterminerInterface::class);
|
|
$mock->expects($this->once())->method('isWorkingDay')->with($date)->willReturn(false);
|
|
$mock1 = $this->createMock(WorkingDayDeterminerInterface::class);
|
|
$mock1->expects($this->never())->method('isWorkingDay');
|
|
$determiner = new MultipleWorkingDayDeterminer([
|
|
$mock,
|
|
$mock1,
|
|
]);
|
|
|
|
$this->assertFalse($determiner->isWorkingDay($date));
|
|
}
|
|
}
|