Skip to content

Commit

Permalink
add: PolarApiNotPermittedException test
Browse files Browse the repository at this point in the history
  • Loading branch information
HDVinnie committed Sep 22, 2024
1 parent 561690c commit 85aedf3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/Exceptions/PolarApiNotPermittedExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

use HDInnovations\LaravelPolarApi\Clients\ArticleClient;
use HDInnovations\LaravelPolarApi\Exceptions\PolarApiNotPermittedException;
use Illuminate\Support\Facades\Http;

it('throws PolarApiNotPermittedException on 403 status', function (): void {
Http::fake([
'*' => Http::response([
'type' => 'NotPermitted',
'detail' => 'string',
], 403),
]);

$client = new ArticleClient('https://api.example.com', 'your-token');

try {
$client->deleteArticle('1');
} catch (PolarApiNotPermittedException $e) {
expect($e->getMessage())->toBe('Not Permitted')
->and($e->getType())->toBe('NotPermitted')
->and($e->getDetail())->toBe('string');
}
});

0 comments on commit 85aedf3

Please sign in to comment.