null, ]); $this->fail('Expected Error was not thrown'); } catch (\Throwable $e) { $this->assertInstanceOf(\InvalidArgumentException::class, $e); $this->assertSame('Notification requires a valid item.', $e->getMessage()); } } public function testAuditNotificationFires() { $webhook_options = [ 'enableSlackWebhook', 'enableMicrosoftTeamsWebhook', 'enableGoogleChatWebhook' ]; Notification::fake(); //tests every webhook option foreach($webhook_options as $option) { $this->settings->{$option}(); $user = User::factory()->create(); $item = Asset::factory()->create(); try { $user->notify(new \App\Notifications\AuditNotification([ 'item' => $item, ])); } catch (\InvalidArgumentException $e) { $this->fail("AuditNotification threw for [{$option}]: {$e->getMessage()}"); } } Notification::assertSentTimes(AuditNotification::class, count($webhook_options)); } }