-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for HTTP 429 - too many requests
- Loading branch information
Vitor de Souza
committed
Sep 6, 2024
1 parent
a97f765
commit cbbaebf
Showing
5 changed files
with
58 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoclerLabs\ApiClientException; | ||
|
||
class TooManyRequestsResponseException extends UnexpectedResponseException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoclerLabs\ApiClientBase\Test\Unit; | ||
|
||
use DoclerLabs\ApiClientException\TooManyRequestsResponseException; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Http\Message\ResponseInterface; | ||
use Throwable; | ||
|
||
/** | ||
* @covers \DoclerLabs\ApiClientException\TooManyRequestsResponseException | ||
*/ | ||
class TooManyRequestsResponseExceptionTest extends TestCase | ||
{ | ||
public function testException(): void | ||
{ | ||
$statusCode = 429; | ||
|
||
/** @var ResponseInterface|MockObject $response */ | ||
$response = $this->createMock(ResponseInterface::class); | ||
$response | ||
->expects(self::once()) | ||
->method('getStatusCode') | ||
->willReturn($statusCode); | ||
|
||
$sut = new TooManyRequestsResponseException('', $response); | ||
|
||
self::assertInstanceOf(Throwable::class, $sut); | ||
self::assertEquals($statusCode, $sut->getResponse()->getStatusCode()); | ||
} | ||
} |