Skip to content

Commit 1dbbb42

Browse files
dev: tests for new http client exceptions (425, 418 and 451).
Signed-off-by: Johannes Tegnér <johannes@jitesoft.com>
1 parent d91ddc8 commit 1dbbb42

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3+
HttpImATeapotExceptionTest.php - Part of the php-exceptions project.
4+
5+
© - Jitesoft
6+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7+
namespace Jitesoft\Exceptions\Tests\Http\Client;
8+
9+
use Jitesoft\Exceptions\Http\Client\HttpImATeapotException;
10+
use Jitesoft\Exceptions\Tests\Http\HttpExceptionTest;
11+
12+
/**
13+
* @group Exceptions
14+
* @group HttpExceptions
15+
* @group RuntimeExceptions
16+
* @group HttpClientExceptions
17+
*/
18+
class HttpImATeapotExceptionTest extends HttpExceptionTest {
19+
20+
protected $expectedErrorCode = 418;
21+
22+
protected function throwDefaultException() {
23+
throw new HttpImATeapotException();
24+
}
25+
26+
public function throwMessageException(string $message) {
27+
throw new HttpImATeapotException($message);
28+
}
29+
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3+
HttpToEarlyExceptionTest.php - Part of the php-exceptions project.
4+
5+
© - Jitesoft
6+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7+
namespace Jitesoft\Exceptions\Tests\Http\Client;
8+
9+
use Jitesoft\Exceptions\Http\Client\HttpToEarlyException;
10+
use Jitesoft\Exceptions\Tests\Http\HttpExceptionTest;
11+
12+
/**
13+
* @group Exceptions
14+
* @group HttpExceptions
15+
* @group RuntimeExceptions
16+
* @group HttpClientExceptions
17+
*/
18+
class HttpToEarlyExceptionTest extends HttpExceptionTest {
19+
20+
protected $expectedErrorCode = 425;
21+
22+
protected function throwDefaultException(): void {
23+
throw new HttpToEarlyException();
24+
}
25+
26+
public function throwMessageException(string $message): void {
27+
throw new HttpToEarlyException($message);
28+
}
29+
30+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
3+
HttpUnavailableForLegalReasonsExceptionTest.php - Part of the php-exceptions project.
4+
5+
© - Jitesoft
6+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7+
namespace Jitesoft\Exceptions\Tests\Http\Client;
8+
9+
use Jitesoft\Exceptions\Http\Client\HttpGoneException;
10+
use Jitesoft\Exceptions\Http\Client\HttpUnavailableForLegalReasonsException;
11+
use Jitesoft\Exceptions\Tests\Http\HttpExceptionTest;
12+
13+
/**
14+
* @group Exceptions
15+
* @group HttpExceptions
16+
* @group RuntimeExceptions
17+
* @group HttpClientExceptions
18+
*/
19+
class HttpUnavailableForLegalReasonsExceptionTest extends HttpExceptionTest {
20+
21+
protected $expectedErrorCode = 451;
22+
23+
protected function throwDefaultException(): void {
24+
throw new HttpUnavailableForLegalReasonsException();
25+
}
26+
27+
public function throwMessageException(string $message): void {
28+
throw new HttpUnavailableForLegalReasonsException($message);
29+
}
30+
31+
}

0 commit comments

Comments
 (0)