refactor(night-contingent) : driver map batch + test cas sans heures
This commit is contained in:
@@ -37,7 +37,9 @@ final class NightContingentExportBuilderTest extends TestCase
|
||||
$workHourRepo->method('findByDateRangeAndEmployees')->willReturn([$whFull, $whShort]);
|
||||
|
||||
$contractResolver = $this->createStub(EmployeeContractResolver::class);
|
||||
$contractResolver->method('resolveIsDriverForEmployeeAndDate')->willReturn(false);
|
||||
$contractResolver->method('resolveIsDriverForEmployeesAndDays')->willReturn([
|
||||
1 => ['2026-01-10' => false, '2026-01-11' => false],
|
||||
]);
|
||||
|
||||
$builder = new NightContingentExportBuilder(
|
||||
$workHourRepo,
|
||||
@@ -68,7 +70,9 @@ final class NightContingentExportBuilderTest extends TestCase
|
||||
$workHourRepo->method('findByDateRangeAndEmployees')->willReturn([$wh]);
|
||||
|
||||
$contractResolver = $this->createStub(EmployeeContractResolver::class);
|
||||
$contractResolver->method('resolveIsDriverForEmployeeAndDate')->willReturn(true);
|
||||
$contractResolver->method('resolveIsDriverForEmployeesAndDays')->willReturn([
|
||||
2 => ['2026-03-05' => true],
|
||||
]);
|
||||
|
||||
$builder = new NightContingentExportBuilder(
|
||||
$workHourRepo,
|
||||
@@ -82,6 +86,31 @@ final class NightContingentExportBuilderTest extends TestCase
|
||||
self::assertSame(1, $rows[0]->months[3]['nightDays']); // 300 >= 240
|
||||
}
|
||||
|
||||
public function testEmployeeWithoutWorkHoursYieldsAllZeroMonths(): void
|
||||
{
|
||||
$employee = $this->makeEmployee(3, 'Durand', 'Marie');
|
||||
|
||||
$workHourRepo = $this->createStub(WorkHourReadRepositoryInterface::class);
|
||||
$workHourRepo->method('findByDateRangeAndEmployees')->willReturn([]);
|
||||
|
||||
$contractResolver = $this->createStub(EmployeeContractResolver::class);
|
||||
$contractResolver->method('resolveIsDriverForEmployeesAndDays')->willReturn([]);
|
||||
|
||||
$builder = new NightContingentExportBuilder(
|
||||
$workHourRepo,
|
||||
$contractResolver,
|
||||
new NightHoursCalculator(),
|
||||
);
|
||||
|
||||
$rows = $builder->buildRows([$employee], 2026);
|
||||
|
||||
self::assertCount(1, $rows);
|
||||
for ($m = 1; $m <= 12; ++$m) {
|
||||
self::assertSame(0, $rows[0]->months[$m]['nightMinutes']);
|
||||
self::assertSame(0, $rows[0]->months[$m]['nightDays']);
|
||||
}
|
||||
}
|
||||
|
||||
private function makeEmployee(int $id, string $last, string $first): Employee
|
||||
{
|
||||
$employee = new Employee();
|
||||
|
||||
Reference in New Issue
Block a user