ldc-cocotte/tests/Integration/WithApp/App/Queries/PickupExceptions/HasAutoUpdatedPickupExceptionsForYearQueryTest.php

41 lines
1.4 KiB
PHP
Raw Normal View History

<?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();
});
});