Skip to content

Commit 201ff7c

Browse files
authored
Merge branch 'main' into bump-meilisearch-v0.26.0
2 parents 84543f3 + 39b371e commit 201ff7c

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

tests/Http/ClientTest.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ public function testPostThrowsWithInvalidResponse(int $statusCode): void
6767

6868
public function testPostThrowsApiException(): void
6969
{
70-
$httpClient = $this->createHttpClientMock(300, '{"message":"internal error"}');
71-
72-
$client = new Client('https://localhost', null, $httpClient);
73-
74-
$this->expectException(ApiException::class);
75-
$this->expectExceptionMessage('internal error');
76-
77-
$client->post('/', '');
70+
try {
71+
$httpClient = $this->createHttpClientMock(300, '{"message":"internal error","code":"internal"}');
72+
$client = new Client('https://localhost', null, $httpClient);
73+
$client->post('/', '');
74+
$this->fail('ApiException not raised.');
75+
} catch (ApiException $e) {
76+
$this->assertEquals('internal', $e->errorCode);
77+
}
7878
}
7979

8080
public function testPutExecutesRequest(): void
@@ -114,14 +114,14 @@ public function testPutThrowsWithInvalidResponse(int $statusCode): void
114114

115115
public function testPutThrowsApiException(): void
116116
{
117-
$httpClient = $this->createHttpClientMock(300, '{"message":"internal error"}');
118-
119-
$client = new Client('https://localhost', null, $httpClient);
120-
121-
$this->expectException(ApiException::class);
122-
$this->expectExceptionMessage('internal error');
123-
124-
$client->put('/', '');
117+
try {
118+
$httpClient = $this->createHttpClientMock(300, '{"message":"internal error","code":"internal"}');
119+
$client = new Client('https://localhost', null, $httpClient);
120+
$client->put('/', '');
121+
$this->fail('ApiException not raised.');
122+
} catch (ApiException $e) {
123+
$this->assertEquals('internal', $e->errorCode);
124+
}
125125
}
126126

127127
public function testPatchExecutesRequest(): void
@@ -161,14 +161,14 @@ public function testPatchThrowsWithInvalidResponse(int $statusCode): void
161161

162162
public function testPatchThrowsApiException(): void
163163
{
164-
$httpClient = $this->createHttpClientMock(300, '{"message":"internal error"}');
165-
166-
$client = new Client('https://localhost', null, $httpClient);
167-
168-
$this->expectException(ApiException::class);
169-
$this->expectExceptionMessage('internal error');
170-
171-
$client->post('/', '');
164+
try {
165+
$httpClient = $this->createHttpClientMock(300, '{"message":"internal error","code":"internal"}');
166+
$client = new Client('https://localhost', null, $httpClient);
167+
$client->patch('/', '');
168+
$this->fail('ApiException not raised.');
169+
} catch (ApiException $e) {
170+
$this->assertEquals('internal', $e->errorCode);
171+
}
172172
}
173173

174174
public function testDeleteExecutesRequest(): void

0 commit comments

Comments
 (0)