diff --git a/tests/Feature/Webhooks/DispatchWebhooksTest.php b/tests/Feature/Webhooks/DispatchWebhooksTest.php index 477927353..ae85ccb7e 100644 --- a/tests/Feature/Webhooks/DispatchWebhooksTest.php +++ b/tests/Feature/Webhooks/DispatchWebhooksTest.php @@ -68,7 +68,7 @@ class DispatchWebhooksTest extends TestCase 'events' => ['eloquent.created: '.Server::class], ]); - $webhookConfig->update(['events' => 'eloquent.deleted: '.Server::class]); + $webhookConfig->update(['events' => ['eloquent.deleted: '.Server::class]]); $this->createServer(); diff --git a/tests/Feature/Webhooks/ProcessWebhooksTest.php b/tests/Feature/Webhooks/ProcessWebhooksTest.php index 40c6a3382..7d991644e 100644 --- a/tests/Feature/Webhooks/ProcessWebhooksTest.php +++ b/tests/Feature/Webhooks/ProcessWebhooksTest.php @@ -64,7 +64,7 @@ class ProcessWebhooksTest extends TestCase ProcessWebhook::dispatchSync( $webhook, 'eloquent.created: '.Server::class, - $data, + [$data], ); $this->assertCount(1, cache()->get("webhooks.$eventName")); @@ -73,7 +73,7 @@ class ProcessWebhooksTest extends TestCase Http::assertSentCount(1); Http::assertSent(function (Request $request) use ($webhook, $data) { return $webhook->endpoint === $request->url() - && $request->data() === $data; + && $request->data() === array_merge($data, ['event' => 'created: Server']); }); } @@ -143,7 +143,7 @@ class ProcessWebhooksTest extends TestCase $this->assertDatabaseCount(Webhook::class, 1); $webhook = Webhook::query()->first(); - $this->assertEquals($server->uuid, $webhook->payload[0]['uuid']); + $this->assertEquals($server->uuid, $webhook->payload['uuid']); $this->assertDatabaseHas(Webhook::class, [ 'endpoint' => $webhookConfig->endpoint, @@ -165,8 +165,11 @@ class ProcessWebhooksTest extends TestCase $server = $this->createServer(); $this->assertDatabaseCount(Webhook::class, 1); + + $webhook = Webhook::query()->first(); + $this->assertEquals($server->uuid, $webhook->payload['uuid']); + $this->assertDatabaseHas(Webhook::class, [ - 'payload' => json_encode([$server->toArray()]), 'endpoint' => $webhookConfig->endpoint, 'successful_at' => null, 'event' => 'eloquent.created: '.Server::class,