+ public function test_event_webhook_call_before()
+ {
+ $args = [];
+ $callback = function (...$eventArgs) use (&$args) {
+ $args = $eventArgs;
+ return ['test' => 'hello!'];
+ };
+ Theme::listen(ThemeEvents::WEBHOOK_CALL_BEFORE, $callback);
+
+ Http::fake([
+ '*' => Http::response('', 200),
+ ]);
+
+ $webhook = new Webhook(['name' => 'Test webhook', 'endpoint' => 'https://example.com']);
+ $webhook->save();
+ $event = ActivityType::PAGE_UPDATE;
+ $detail = Page::query()->first();
+
+ dispatch((new DispatchWebhookJob($webhook, $event, $detail)));
+
+ $this->assertCount(3, $args);
+ $this->assertEquals($event, $args[0]);
+ $this->assertEquals($webhook->id, $args[1]->id);
+ $this->assertEquals($detail->id, $args[2]->id);
+
+ Http::assertSent(function (HttpClientRequest $request) {
+ return $request->isJson() && $request->data()['test'] === 'hello!';
+ });
+ }
+