forceCreate([ 'email' => new Email('reminder@example.com'), 'hashcode' => (string) Str::uuid(), ]); /** @var Employee $employee */ $employee = Employee::query()->forceCreate([ 'customer_id' => $customer->id, 'matricule' => new Matricule('1234567'), 'nom' => 'Dupont', 'prenom' => 'Jean', 'code' => new Code('ABC1234'), 'etablissement' => new ShopperEstablishmentCode('01'), 'site' => new ShopperSiteCode('SITE'), 'service' => new ShopperServiceCode('01'), 'start_date' => CarbonImmutable::now()->subMonth(), 'end_date' => CarbonImmutable::now()->addMonth(), ]); $pickupExceptionRepo = \Mockery::mock(PickupExceptionRepository::class); $schedulingService = new PickupSchedulingService($pickupExceptionRepo); $icsGenerator = new IcsGeneratorService('Cocotte Test'); // WHEN new SendMissingOrderReminderJob()->handle($schedulingService, $icsGenerator); // THEN Notification::assertSentTo( $employee, MissingOrderReminderNotification::class, function (MissingOrderReminderNotification $notification) use ($employee): bool { $mail = $notification->toMail($employee); return count($mail->rawAttachments) === 1 && $mail->rawAttachments[0]['name'] === 'rappel-commande.ics' && str_contains((string) $mail->rawAttachments[0]['data'], 'BEGIN:VCALENDAR'); } ); Date::setTestNow(); }); });