Skip to content

Commit 8de1e70

Browse files
committed
refactor: DefaultSignerTest
1 parent c4b6f4b commit 8de1e70

File tree

2 files changed

+13
-29
lines changed

2 files changed

+13
-29
lines changed

tests/CallWebhookJobTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
namespace Spatie\WebhookServer\Tests;
4-
53
use GuzzleHttp\Client;
64
use GuzzleHttp\Exception\ConnectException;
75
use GuzzleHttp\TransferStats;
@@ -282,8 +280,8 @@ function baseGetRequest(array $overrides = []): array
282280
artisan('queue:work --once');
283281

284282
Event::assertDispatched(WebhookCallFailedEvent::class, function (WebhookCallFailedEvent $event) {
285-
$this->assertNotNull($event->errorType);
286-
$this->assertNotNull($event->errorMessage);
283+
expect($event->errorType)->not->toBeNull()
284+
->and($event->errorMessage)->not->toBeNull();
287285

288286
return true;
289287
});
@@ -297,7 +295,7 @@ function baseGetRequest(array $overrides = []): array
297295
artisan('queue:work --once');
298296

299297
Event::assertDispatched(JobFailed::class, function (JobFailed $event) {
300-
$this->assertInstanceOf(ConnectException::class, $event->exception);
298+
expect($event->exception)->toBeInstanceOf(ConnectException::class);
301299

302300
return true;
303301
});

tests/DefaultSignerTest.php

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,18 @@
11
<?php
22

3-
namespace Spatie\WebhookServer\Tests;
4-
53
use Spatie\WebhookServer\Signer\DefaultSigner;
64

7-
class DefaultSignerTest extends TestCase
8-
{
9-
/** @test */
10-
public function it_can_calculate_a_signature_for_a_given_payload_and_secret()
11-
{
12-
$signer = new DefaultSigner();
5+
it('can calculate a signature for a given payload and secret', function () {
6+
$signer = new DefaultSigner();
137

14-
$signature = $signer->calculateSignature('https://my.app/webhooks', ['a' => '1'], 'abc');
8+
$signature = $signer->calculateSignature('https://my.app/webhooks', ['a' => '1'], 'abc');
159

16-
$this->assertEquals(
17-
'345611a3626cf5e080a7a412184001882ab231b8bdb465dc76dbf709f01f210a',
18-
$signature,
19-
);
20-
}
10+
expect($signature)->toEqual('345611a3626cf5e080a7a412184001882ab231b8bdb465dc76dbf709f01f210a');
11+
});
2112

22-
/** @test */
23-
public function it_can_return_the_name_of_the_signature_header()
24-
{
25-
$signer = new DefaultSigner();
13+
it('can return the name of the signature header', function () {
14+
$signer = new DefaultSigner();
2615

27-
$this->assertEquals(
28-
config('webhook-server.signature_header_name'),
29-
$signer->signatureHeaderName(),
30-
);
31-
}
32-
}
16+
expect($signer->signatureHeaderName())
17+
->toEqual(config('webhook-server.signature_header_name'));
18+
});

0 commit comments

Comments
 (0)