handle(); Notification::assertSentTo( new AnonymousNotifiable(), DiscordNotification::class, ); } /** * The Send Discord Notification Job shall use the RateLimited middleware. * * @return void */ public function testRateLimited(): void { $event = new class implements DiscordMessageEvent { use Dispatchable; /** * Get Discord message payload. * * @return DiscordMessage */ public function getDiscordMessage(): DiscordMessage { return DiscordMessage::create(); } /** * Get Discord channel the message will be sent to. * * @return string */ public function getDiscordChannel(): string { return ''; } /** * Determine if the message should be sent. * * @return bool */ public function shouldSendDiscordMessage(): bool { return true; } }; $job = new SendDiscordNotificationJob($event); $middleware = collect($job->middleware())->first(); static::assertInstanceOf(RateLimited::class, $middleware); } }