Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Jun 13, 2019
1 parent 7e85049 commit 97d75bf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/TestClasses/ProcessNothingWebhookProfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Spatie\WebhookClient\Tests\TestClasses;

use Illuminate\Http\Request;
use Spatie\WebhookClient\WebhookProfile\WebhookProfile;

class ProcessNothingWebhookProfile implements WebhookProfile
{
public function shouldProcess(Request $request): bool
{
return false;
}
}

15 changes: 15 additions & 0 deletions tests/WebhookControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Support\Facades\Route;
use Spatie\WebhookClient\Events\InvalidSignatureEvent;
use Spatie\WebhookClient\Models\WebhookCall;
use Spatie\WebhookClient\Tests\TestClasses\ProcessNothingWebhookProfile;
use Spatie\WebhookClient\Tests\TestClasses\ProcessWebhookJobTestClass;

class WebhookControllerTest extends TestCase
Expand Down Expand Up @@ -75,6 +76,20 @@ public function a_request_with_an_invalid_payload_will_not_get_processed()
Event::assertDispatched(InvalidSignatureEvent::class);
}

/** @test */
public function it_can_work_with_an_alternative_profile()
{
config()->set('webhook-client.0.webhook_profile', ProcessNothingWebhookProfile::class);

$this
->postJson('incoming-webhooks', $this->payload, $this->headers)
->assertSuccessful();

Queue::assertNothingPushed();
Event::assertNotDispatched(InvalidSignatureEvent::class);
$this->assertCount(0, WebhookCall::get());
}

private function determineSignature(array $payload): string
{
$secret = config('webhook-client.0.signing_secret');
Expand Down

0 comments on commit 97d75bf

Please sign in to comment.