mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-06 00:09:24 +03:00
Add forbidden response test cases
This commit is contained in:
parent
e0cb8023a7
commit
4a2a4fe4a5
@ -34,4 +34,30 @@ class HttpClientExceptionTest extends MailgunTestCase
|
|||||||
$exception = HttpClientException::badRequest($response);
|
$exception = HttpClientException::badRequest($response);
|
||||||
$this->assertStringEndsWith('<html><body>Server HTML</body></html>', $exception->getMessage());
|
$this->assertStringEndsWith('<html><body>Server HTML</body></html>', $exception->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testForbiddenRequestThrowException()
|
||||||
|
{
|
||||||
|
$response = new Response(403, ['Content-Type' => 'application/json'], '{"Error":"Business Verification"}');
|
||||||
|
$exception = HttpClientException::forbidden($response);
|
||||||
|
$this->assertInstanceOf(HttpClientException::class, $exception);
|
||||||
|
$this->assertSame(403, $exception->getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testForbiddenRequestGetMessageJson()
|
||||||
|
{
|
||||||
|
$response = new Response(403, ['Content-Type' => 'application/json'], '{"Error":"Business Verification"}');
|
||||||
|
$exception = HttpClientException::forbidden($response);
|
||||||
|
$this->assertStringEndsWith('Business Verification', $exception->getMessage());
|
||||||
|
|
||||||
|
$response = new Response(403, ['Content-Type' => 'application/json'], '{"Message":"Business Verification"}');
|
||||||
|
$exception = HttpClientException::forbidden($response);
|
||||||
|
$this->assertStringEndsWith('{"Message":"Business Verification"}', $exception->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testForbiddenRequestGetMessage()
|
||||||
|
{
|
||||||
|
$response = new Response(400, ['Content-Type' => 'text/html'], '<html><body>Forbidden</body></html>');
|
||||||
|
$exception = HttpClientException::badRequest($response);
|
||||||
|
$this->assertStringEndsWith('<html><body>Forbidden</body></html>', $exception->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user