create([ 'events' => ['eloquent.created: '.Server::class], ]); $this->createServer(); Queue::assertPushed(ProcessWebhook::class); } public function test_sends_multiple_webhooks() { WebhookConfiguration::factory(2) ->create(['events' => ['eloquent.created: '.Server::class]]); $this->createServer(); Queue::assertPushed(ProcessWebhook::class, 2); } public function test_it_sends_no_webhooks() { WebhookConfiguration::factory()->create(); $this->createServer(); Queue::assertNothingPushed(); } public function test_it_sends_some_webhooks() { WebhookConfiguration::factory(2) ->sequence( ['events' => ['eloquent.created: '.Server::class]], ['events' => ['eloquent.deleted: '.Server::class]] )->create(); $this->createServer(); Queue::assertPushed(ProcessWebhook::class, 1); } public function test_it_does_not_call_removed_events() { $webhookConfig = WebhookConfiguration::factory()->create([ 'events' => ['eloquent.created: '.Server::class], ]); $webhookConfig->update(['events' => 'eloquent.deleted: '.Server::class]); $this->createServer(); Queue::assertNothingPushed(); } public function test_it_does_not_call_deleted_webhooks() { $webhookConfig = WebhookConfiguration::factory()->create([ 'events' => ['eloquent.created: '.Server::class], ]); $webhookConfig->delete(); $this->createServer(); Queue::assertNothingPushed(); } public function createServer(): Server { return Server::factory()->withNode()->create(); } }