feat : ajout des suspensions et des jours de présence
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
This commit is contained in:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Tests\Service\Leave;
|
||||
|
||||
use App\Service\Leave\LeaveBalanceComputationService;
|
||||
use App\Service\Leave\SuspensionDaysCalculator;
|
||||
use DateTimeImmutable;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionClass;
|
||||
@@ -16,7 +17,7 @@ final class LeaveBalanceComputationServiceTest extends TestCase
|
||||
{
|
||||
public function testComputeAccruedDaysProratesPartialFirstMonth(): void
|
||||
{
|
||||
$service = new ReflectionClass(LeaveBalanceComputationService::class)->newInstanceWithoutConstructor();
|
||||
$service = $this->createServiceWithoutConstructor();
|
||||
$method = new ReflectionClass(LeaveBalanceComputationService::class)->getMethod('computeAccruedDays');
|
||||
|
||||
$result = $method->invoke(
|
||||
@@ -32,7 +33,7 @@ final class LeaveBalanceComputationServiceTest extends TestCase
|
||||
|
||||
public function testComputeAccruedDaysTotalMatchesAlainCase(): void
|
||||
{
|
||||
$service = new ReflectionClass(LeaveBalanceComputationService::class)->newInstanceWithoutConstructor();
|
||||
$service = $this->createServiceWithoutConstructor();
|
||||
$method = new ReflectionClass(LeaveBalanceComputationService::class)->getMethod('computeAccruedDays');
|
||||
|
||||
$days = $method->invoke(
|
||||
@@ -55,7 +56,7 @@ final class LeaveBalanceComputationServiceTest extends TestCase
|
||||
|
||||
public function testComputeAccruedDaysIncludesLastDayOfMonthDespiteTimeComponents(): void
|
||||
{
|
||||
$service = new ReflectionClass(LeaveBalanceComputationService::class)->newInstanceWithoutConstructor();
|
||||
$service = $this->createServiceWithoutConstructor();
|
||||
$method = new ReflectionClass(LeaveBalanceComputationService::class)->getMethod('computeAccruedDays');
|
||||
|
||||
$result = $method->invoke(
|
||||
@@ -68,4 +69,15 @@ final class LeaveBalanceComputationServiceTest extends TestCase
|
||||
|
||||
self::assertEqualsWithDelta(25.0 / 12.0, $result, 0.0001);
|
||||
}
|
||||
|
||||
private function createServiceWithoutConstructor(): LeaveBalanceComputationService
|
||||
{
|
||||
$rc = new ReflectionClass(LeaveBalanceComputationService::class);
|
||||
$service = $rc->newInstanceWithoutConstructor();
|
||||
|
||||
$prop = $rc->getProperty('suspensionDaysCalculator');
|
||||
$prop->setValue($service, new SuspensionDaysCalculator());
|
||||
|
||||
return $service;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user