Skip to content

Commit

Permalink
SP-1024 Adding stricter assertions to unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kwiatkowski committed Nov 28, 2024
1 parent bfe874e commit 76a71e3
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Features\Shared\Configuration\BitPayConfigurationInterface;
use App\Features\Invoice\UpdateInvoice\BitPaySignatureValidator;
use App\Shared\Exceptions\SignatureVerificationFailed;
use Tests\Unit\AbstractUnitTestCase;

class ValidateBitPayWebhookTest extends AbstractUnitTestCase
Expand All @@ -22,9 +23,7 @@ public function it_should_return_error_when_signing_key_is_missing(): void

$validator = new BitPaySignatureValidator($bitpayConfig);
$this->expectException(\RuntimeException::class);
$validator->execute([], [
'x-signature' => 'test-signature',
]);
$validator->execute([], []);
}

/**
Expand All @@ -33,8 +32,12 @@ public function it_should_return_error_when_signing_key_is_missing(): void
public function it_should_return_error_when_signature_header_is_missing(): void
{
$bitpayConfig = $this->createMock(BitPayConfigurationInterface::class);
$bitpayConfig->expects($this->once())
->method('getToken')
->willReturn('test-token');

$validator = new BitPaySignatureValidator($bitpayConfig);
$this->expectException(\RuntimeException::class);
$this->expectException(SignatureVerificationFailed::class);

$validator->execute([], []);
}
Expand All @@ -49,10 +52,10 @@ public function it_should_return_error_when_signature_does_not_match(): void
->method('getToken')
->willReturn('test-token');

$headers = ['x-signature' => 'invalid-signature'];
$headers = ['x-signature' => ['invalid-signature']];

$validator = new BitPaySignatureValidator($bitpayConfig);
$this->expectException(\RuntimeException::class);
$this->expectException(SignatureVerificationFailed::class);
$validator->execute([], $headers);
}

Expand Down

0 comments on commit 76a71e3

Please sign in to comment.