fix : calcule des congés en cours d'acquisition au prorata (date début contrat)
This commit is contained in:
71
tests/State/EmployeeLeaveSummaryProviderTest.php
Normal file
71
tests/State/EmployeeLeaveSummaryProviderTest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\State;
|
||||
|
||||
use App\State\EmployeeLeaveSummaryProvider;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class EmployeeLeaveSummaryProviderTest extends TestCase
|
||||
{
|
||||
public function testComputeAccruedDaysFromStartProratesPartialFirstMonth(): void
|
||||
{
|
||||
$provider = new ReflectionClass(EmployeeLeaveSummaryProvider::class)->newInstanceWithoutConstructor();
|
||||
$method = new ReflectionClass(EmployeeLeaveSummaryProvider::class)->getMethod('computeAccruedDaysFromStart');
|
||||
|
||||
$result = $method->invoke(
|
||||
$provider,
|
||||
25.0,
|
||||
25.0 / 12.0,
|
||||
new DateTimeImmutable('2025-06-10'),
|
||||
new DateTimeImmutable('2026-02-28')
|
||||
);
|
||||
|
||||
self::assertEqualsWithDelta(18.125, $result, 0.0001);
|
||||
}
|
||||
|
||||
public function testComputeAccruingDaysTotalMatchesAlainCase(): void
|
||||
{
|
||||
$provider = new ReflectionClass(EmployeeLeaveSummaryProvider::class)->newInstanceWithoutConstructor();
|
||||
$method = new ReflectionClass(EmployeeLeaveSummaryProvider::class)->getMethod('computeAccruedDaysFromStart');
|
||||
|
||||
$days = $method->invoke(
|
||||
$provider,
|
||||
25.0,
|
||||
25.0 / 12.0,
|
||||
new DateTimeImmutable('2025-06-10'),
|
||||
new DateTimeImmutable('2026-02-28')
|
||||
);
|
||||
$saturdays = $method->invoke(
|
||||
$provider,
|
||||
5.0,
|
||||
5.0 / 12.0,
|
||||
new DateTimeImmutable('2025-06-10'),
|
||||
new DateTimeImmutable('2026-02-28')
|
||||
);
|
||||
|
||||
self::assertEqualsWithDelta(21.75, $days + $saturdays, 0.0001);
|
||||
}
|
||||
|
||||
public function testComputeAccruedDaysFromStartIncludesLastDayOfMonth(): void
|
||||
{
|
||||
$provider = new ReflectionClass(EmployeeLeaveSummaryProvider::class)->newInstanceWithoutConstructor();
|
||||
$method = new ReflectionClass(EmployeeLeaveSummaryProvider::class)->getMethod('computeAccruedDaysFromStart');
|
||||
|
||||
$result = $method->invoke(
|
||||
$provider,
|
||||
25.0,
|
||||
25.0 / 12.0,
|
||||
new DateTimeImmutable('2026-02-01 12:50:18'),
|
||||
new DateTimeImmutable('2026-02-28 00:00:00')
|
||||
);
|
||||
|
||||
self::assertEqualsWithDelta(25.0 / 12.0, $result, 0.0001);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user