66
77use Meilisearch \Exceptions \ApiException ;
88use Meilisearch \Exceptions \InvalidResponseBodyException ;
9- use Meilisearch \Exceptions \JsonDecodingException ;
10- use Meilisearch \Exceptions \JsonEncodingException ;
119use Meilisearch \Http \Client ;
1210use Meilisearch \Meilisearch ;
1311use PHPUnit \Framework \MockObject \MockObject ;
@@ -57,8 +55,8 @@ public function testPostThrowsWithInvalidBody(): void
5755 {
5856 $ client = new Client ('https://localhost ' );
5957
60- $ this ->expectException (JsonEncodingException ::class);
61- $ this ->expectExceptionMessage ('Encoding payload to json failed: " Malformed UTF-8 characters, possibly incorrectly encoded". ' );
58+ $ this ->expectException (\JsonException ::class);
59+ $ this ->expectExceptionMessage ('Malformed UTF-8 characters, possibly incorrectly encoded ' );
6260
6361 $ client ->post ('/ ' , "{'Bad JSON': \xB1\x31} " );
6462 }
@@ -72,8 +70,8 @@ public function testPostThrowsWithInvalidResponse(int $statusCode): void
7270
7371 $ client = new Client ('https://localhost ' , null , $ httpClient );
7472
75- $ this ->expectException (JsonDecodingException ::class);
76- $ this ->expectExceptionMessage ('Decoding payload to json failed: " Syntax error" ' );
73+ $ this ->expectException (\JsonException ::class);
74+ $ this ->expectExceptionMessage ('Syntax error ' );
7775
7876 $ client ->post ('/ ' , '' );
7977 }
@@ -104,8 +102,8 @@ public function testPutThrowsWithInvalidBody(): void
104102 {
105103 $ client = new Client ('https://localhost ' );
106104
107- $ this ->expectException (JsonEncodingException ::class);
108- $ this ->expectExceptionMessage ('Encoding payload to json failed: " Malformed UTF-8 characters, possibly incorrectly encoded". ' );
105+ $ this ->expectException (\JsonException ::class);
106+ $ this ->expectExceptionMessage ('Malformed UTF-8 characters, possibly incorrectly encoded ' );
109107
110108 $ client ->put ('/ ' , "{'Bad JSON': \xB1\x31} " );
111109 }
@@ -119,8 +117,8 @@ public function testPutThrowsWithInvalidResponse(int $statusCode): void
119117
120118 $ client = new Client ('https://localhost ' , null , $ httpClient );
121119
122- $ this ->expectException (JsonDecodingException ::class);
123- $ this ->expectExceptionMessage ('Decoding payload to json failed: " Syntax error" ' );
120+ $ this ->expectException (\JsonException ::class);
121+ $ this ->expectExceptionMessage ('Syntax error ' );
124122
125123 $ client ->put ('/ ' , '' );
126124 }
@@ -151,8 +149,8 @@ public function testPatchThrowsWithInvalidBody(): void
151149 {
152150 $ client = new Client ('https://localhost ' );
153151
154- $ this ->expectException (JsonEncodingException ::class);
155- $ this ->expectExceptionMessage ('Encoding payload to json failed: " Malformed UTF-8 characters, possibly incorrectly encoded". ' );
152+ $ this ->expectException (\JsonException ::class);
153+ $ this ->expectExceptionMessage ('Malformed UTF-8 characters, possibly incorrectly encoded ' );
156154
157155 $ client ->patch ('/ ' , "{'Bad JSON': \xB1\x31} " );
158156 }
@@ -166,8 +164,8 @@ public function testPatchThrowsWithInvalidResponse(int $statusCode): void
166164
167165 $ client = new Client ('https://localhost ' , null , $ httpClient );
168166
169- $ this ->expectException (JsonDecodingException ::class);
170- $ this ->expectExceptionMessage ('Decoding payload to json failed: " Syntax error" ' );
167+ $ this ->expectException (\JsonException ::class);
168+ $ this ->expectExceptionMessage ('Syntax error ' );
171169
172170 $ client ->put ('/ ' , '' );
173171 }
0 commit comments