ldc-cocotte/tests/Integration/WithApp/App/Queries/PickupExceptions/HasAutoUpdatedPickupExceptionsForYearQueryTest.php
Jérémy Munsch faef51091e
feat(pickup-exceptions): implement upsert and query for public holidays
Added functionality to upsert pickup exceptions for public holidays
and query for auto-updated exceptions. This includes new classes
for handling input and service integration with the public holidays API.
2026-11-15 20:04:29 +01:00

40 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
use App\Cqs\Queries\PickupExceptions\HasAutoUpdatedPickupExceptionsForYearQuery;
use App\Cqs\Queries\PickupExceptions\HasAutoUpdatedPickupExceptionsForYearQueryInput;
use App\Models\PickupException;
use Domain\Enums\RepeatFrequency;
describe('HasAutoUpdatedPickupExceptionsForYearQuery', function (): void {
it('returns true only when auto-updated pickup exceptions exist for the given year', function (): void {
// GIVEN
PickupException::factory()->create([
'date' => '2026-05-01',
'label' => 'Manual exception',
'repeatable' => false,
'repeat_frequency' => RepeatFrequency::YEARLY,
'auto_updated' => false,
]);
$query = new HasAutoUpdatedPickupExceptionsForYearQuery();
// WHEN
$beforeAuto = $query(new HasAutoUpdatedPickupExceptionsForYearQueryInput(2026));
PickupException::factory()->create([
'date' => '2026-01-01',
'label' => '1er janvier',
'repeatable' => true,
'repeat_frequency' => RepeatFrequency::YEARLY,
'auto_updated' => true,
]);
$afterAuto = $query(new HasAutoUpdatedPickupExceptionsForYearQueryInput(2026));
// THEN
expect($beforeAuto)->toBeFalse()
->and($afterAuto)->toBeTrue();
});
});