create(); $customer = Customer::query()->forceCreate([ 'email' => new Email('today-reminder@example.com'), 'hashcode' => (string) Str::uuid(), ]); $employee = Employee::query()->forceCreate([ 'customer_id' => $customer->id, 'matricule' => new Matricule('5234567'), 'nom' => 'Bernard', 'prenom' => 'Alice', 'code' => new Code('MNQ2345'), 'etablissement' => new ShopperEstablishmentCode('01'), 'site' => new ShopperSiteCode('SITE'), 'service' => new ShopperServiceCode('01'), ]); $order = Order::forceCreate([ 'id' => Uuid::uuid7()->toString(), 'shop_id' => $shop->id, 'reference' => new OrderReference(Uuid::uuid7()), 'status' => OrderStatus::VALIDATED->value, 'total' => new Money(3000, new Currency('EUR')), 'employee' => new OrderEmployee( new Matricule('5234567'), 'Alice', 'Bernard', new ShopperEstablishmentCode('01'), new ShopperSiteCode('SITE'), new ShopperServiceCode('01'), ), 'delivery_address' => new DeliveryAddress('Shop', '1 rue Test', '75000', 'Paris'), 'pickup_day' => '2026-11-20', ]); $formatter = \Mockery::mock(MoneyFormatter::class); $formatter->shouldReceive('format')->once()->andReturn('30,00 €'); $executor = $this->app->make(Executor::class); $claimAction = new ClaimTodayOrderReminder(); $job = new SendReminderMail($formatter); // WHEN $job->handle($executor, $claimAction); // Re-running on same day (e.g. retry or duplicate run) must not notify twice. $job->handle($executor, $claimAction); // THEN Notification::assertSentToTimes($employee, OrderTodayReminderNotification::class, 1); expect($order->fresh()?->reminded_at)->not->toBeNull() ->and($job->uniqueId())->toBe('2026-11-20'); Date::setTestNow(); }); });