date = $parisMidnight; $exception->label = 'Victoire 1945'; $exception->repeatable = true; $exception->repeat_frequency = RepeatFrequency::YEARLY; $exception->setAttribute('auto_updated', true); // WHEN $exception->saveOrFail(); $rawDate = DB::table('pickup_exceptions')->where('id', $exception->id)->value('date'); $reloaded = PickupException::query()->findOrFail($exception->id); // THEN expect($rawDate)->toBe('2026-05-08') ->and($reloaded->date->format('Y-m-d'))->toBe('2026-05-08') ->and($reloaded->date->timezoneName)->toBe('UTC'); }); it('preserves calendar date for CarbonImmutable midnight and returns startOfDay UTC', function (): void { // GIVEN $cast = new CalendarDateCast(); $model = new PickupException(); $parisImmutable = CarbonImmutable::parse('2026-05-08 00:00:00', 'Europe/Paris'); // WHEN $storedDate = $cast->set($model, 'date', $parisImmutable, []); $readDate = $cast->get($model, 'date', '2026-05-08', []); // THEN expect($storedDate)->toBe('2026-05-08') ->and($readDate?->format('Y-m-d H:i:s'))->toBe('2026-05-08 00:00:00') ->and($readDate?->timezoneName)->toBe('UTC'); }); });