File tree Expand file tree Collapse file tree 5 files changed +107
-18
lines changed Expand file tree Collapse file tree 5 files changed +107
-18
lines changed Original file line number Diff line number Diff line change 1
1
version : 2
2
2
3
3
jobs :
4
- php72 :
4
+
5
+ php74 :
5
6
docker :
6
- - image : circleci/php:7.2 -cli
7
+ - image : circleci/php:7.4 -cli
7
8
8
9
working_directory : ~/project
9
10
steps :
10
11
- checkout
11
12
- run :
12
13
name : Run tests / Symfony 4^3
13
14
command : |
14
- composer update -n --prefer-dist --prefer-stable --no-suggest
15
+ composer update -n --prefer-dist --prefer-stable
15
16
php vendor/bin/phpunit
16
17
17
18
- run :
18
19
name : Run tests / Symfony 5^0
19
20
command : |
20
- composer update -n --prefer-dist --no-suggest
21
+ composer update -n --prefer-dist
21
22
php vendor/bin/phpunit
22
23
23
- php74 :
24
+ php80 :
24
25
docker :
25
- - image : circleci/php:7.4 -cli
26
+ - image : circleci/php:8.0 -cli
26
27
27
28
working_directory : ~/project
28
29
steps :
29
30
- checkout
30
31
- run :
31
- name : Run tests / Symfony 4^3
32
- command : |
33
- composer update -n --prefer-dist --prefer-stable --no-suggest
34
- php vendor/bin/phpunit
35
-
36
- - run :
37
- name : Run tests / Symfony 5^0
32
+ name : Run tests
38
33
command : |
39
- composer update -n --prefer-dist --no-suggest
34
+ composer update -n --prefer-dist
40
35
php vendor/bin/phpunit
41
36
42
37
workflows :
43
38
version : 2
44
39
test :
45
40
jobs :
46
- - php72
47
- - php74
41
+ - php74
42
+ - php80
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Apisearch PHP Client.
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ *
9
+ * Feel free to edit as you please, and have fun.
10
+ *
11
+ * @author Marc Morera <yuhu@mmoreram.com>
12
+ */
13
+
14
+ declare (strict_types=1 );
15
+
16
+ namespace Apisearch \Exception ;
17
+
18
+ /**
19
+ * Class EmptyBodyException.
20
+ */
21
+ class PayloadTooLargeException extends TransportableException
22
+ {
23
+ /**
24
+ * @return int
25
+ */
26
+ public static function getTransportableHTTPError (): int
27
+ {
28
+ return 413 ;
29
+ }
30
+
31
+ /**
32
+ * @return self
33
+ */
34
+ public static function create (): self
35
+ {
36
+ return new static ('You sent us a too large payload. Please, consider reducing this size. ' );
37
+ }
38
+ }
Original file line number Diff line number Diff line change 19
19
use Apisearch \Exception \ForbiddenException ;
20
20
use Apisearch \Exception \InvalidFormatException ;
21
21
use Apisearch \Exception \InvalidTokenException ;
22
+ use Apisearch \Exception \PayloadTooLargeException ;
22
23
use Apisearch \Exception \ResourceExistsException ;
23
24
use Apisearch \Exception \ResourceNotAvailableException ;
24
25
use Apisearch \Exception \TooManyRequestsException ;
@@ -60,6 +61,8 @@ protected static function throwTransportableExceptionIfNeeded(
60
61
throw new ForbiddenException ($ response ['body ' ]['message ' ]);
61
62
case TooManyRequestsException::getTransportableHTTPError ():
62
63
throw new TooManyRequestsException ($ response ['body ' ]['message ' ]);
64
+ case PayloadTooLargeException::getTransportableHTTPError ():
65
+ throw new PayloadTooLargeException ($ response ['body ' ]['message ' ]);
63
66
case ConnectionException::getTransportableHTTPError ():
64
67
throw new ConnectionException ('Apisearch returned an internal error code [500] - ' .$ response ['body ' ]['message ' ]);
65
68
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the Apisearch PHP Client.
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ *
9
+ * Feel free to edit as you please, and have fun.
10
+ *
11
+ * @author Marc Morera <yuhu@mmoreram.com>
12
+ */
13
+
14
+ declare (strict_types=1 );
15
+
16
+ namespace Apisearch \Tests \Exception ;
17
+
18
+ use Apisearch \Exception \PayloadTooLargeException ;
19
+ use Apisearch \Exception \TransportableException ;
20
+ use PHPUnit \Framework \TestCase ;
21
+
22
+ /**
23
+ * Class PayloadTooLargeExceptionTest.
24
+ */
25
+ class PayloadTooLargeExceptionTest extends TestCase
26
+ {
27
+ /**
28
+ * Assert that returns proper transportable error.
29
+ */
30
+ public function testTransportableErrorCode ()
31
+ {
32
+ $ this ->assertInstanceOf (
33
+ TransportableException::class,
34
+ new PayloadTooLargeException ()
35
+ );
36
+
37
+ $ this ->assertEquals (
38
+ 413 ,
39
+ PayloadTooLargeException::getTransportableHTTPError ()
40
+ );
41
+ }
42
+
43
+ /**
44
+ * Assert that extends an exception.
45
+ */
46
+ public function testExtendsException ()
47
+ {
48
+ $ this ->assertInstanceOf (
49
+ \Exception::class,
50
+ new PayloadTooLargeException ()
51
+ );
52
+ }
53
+ }
Original file line number Diff line number Diff line change 10
10
}
11
11
],
12
12
"require" : {
13
- "php" : " >=7.2 " ,
13
+ "php" : " ^7.4 | ^8.0 " ,
14
14
"ext-curl" : " *" ,
15
15
"symfony/event-dispatcher" : " ^3.4 || ^4.0 || ^5.0" ,
16
16
"symfony/yaml" : " ^3.4 || ^4.0 || ^5.0" ,
17
17
"nesbot/carbon" : " ^1.22 || ^2.0"
18
18
},
19
19
"require-dev" : {
20
- "phpunit/phpunit" : " 7.5.17 "
20
+ "phpunit/phpunit" : " ^9 "
21
21
},
22
22
"autoload" : {
23
23
"psr-4" : {
You can’t perform that action at this time.
0 commit comments