Skip to content

Commit

Permalink
Merge pull request #82 from dmason30/dispatch_sync
Browse files Browse the repository at this point in the history
Add dispatchSync method
  • Loading branch information
freekmurze authored Apr 28, 2021
2 parents 5efc998 + d6c105b commit ea5d717
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/WebhookCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ public function dispatchNow()
return dispatch_now($this->callWebhookJob);
}

public function dispatchSync(): void
{
if (function_exists('dispatch_sync')) {
$this->prepareForDispatch();

dispatch_sync($this->callWebhookJob);
return;
}

$this->dispatchNow();
}

protected function prepareForDispatch(): void
{
if (! $this->callWebhookJob->webhookUrl) {
Expand Down
12 changes: 11 additions & 1 deletion tests/CallWebhookJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function it_can_make_a_webhook_call()
}

/** @test */
public function it_can_make_a_synchronous_webhook_call()
public function it_can_make_a_legacy_synchronous_webhook_call()
{
$this->baseWebhook()->dispatchNow();

Expand All @@ -52,6 +52,16 @@ public function it_can_make_a_synchronous_webhook_call()
->assertRequestsMade([$this->baseRequest()]);
}

/** @test */
public function it_can_make_a_synchronous_webhook_call()
{
$this->baseWebhook()->dispatchSync();

$this
->testClient
->assertRequestsMade([$this->baseRequest()]);
}

/** @test */
public function it_can_use_a_different_http_verb()
{
Expand Down

0 comments on commit ea5d717

Please sign in to comment.