49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Services\WorkingDays\Date;
|
|
|
|
use App\Services\WorkingDays\Date\MonToFriWorkingDayDeterminer;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class MonToFriWorkingDayDeterminerTest extends TestCase
|
|
{
|
|
#[DataProvider('nonWorkingDayProvider')]
|
|
public function testIsWorkingDayWillReturnFalseForSatSan(int $day): void
|
|
{
|
|
$class = new MonToFriWorkingDayDeterminer();
|
|
|
|
$this->assertFalse($class->isWorkingDay(new \DateTimeImmutable("2024-01-0" . $day)));
|
|
}
|
|
|
|
/**
|
|
* @return array<int, array<int, int>>
|
|
*/
|
|
public static function nonWorkingDayProvider(): array
|
|
{
|
|
return [[6], [7]];
|
|
}
|
|
|
|
/**
|
|
* @return \Generator<int, array<int>>
|
|
*/
|
|
public static function workingDayProvider(): \Generator
|
|
{
|
|
for ($isNWD = 0; $isNWD <= 1; $isNWD++) {
|
|
for ($x = 1; $x <= 5; $x++) {
|
|
yield [$x];
|
|
}
|
|
}
|
|
}
|
|
|
|
#[DataProvider('workingDayProvider')]
|
|
public function testIsWorkingDayWillCallIsNWDForWorkingDaysAndReturnValue(int $day): void
|
|
{
|
|
$class = new MonToFriWorkingDayDeterminer();
|
|
|
|
$this->assertSame(true, $class->isWorkingDay(new \DateTimeImmutable("2024-01-0" . $day)));
|
|
}
|
|
}
|