Add missing charset to content-type for Slack notifier
This commit is contained in:
parent
b802c6d98d
commit
e642100ea5
@ -80,6 +80,9 @@ final class SlackTransport extends AbstractTransport
|
||||
$response = $this->client->request('POST', 'https://'.$this->getEndpoint().'/api/chat.postMessage', [
|
||||
'json' => array_filter($options),
|
||||
'auth_bearer' => $this->accessToken,
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json; charset=utf-8',
|
||||
],
|
||||
]);
|
||||
|
||||
if (200 !== $response->getStatusCode()) {
|
||||
|
@ -207,4 +207,27 @@ final class SlackTransportTest extends TransportTestCase
|
||||
|
||||
$transport->send(new ChatMessage('testMessage'));
|
||||
}
|
||||
|
||||
public function testSendIncludesContentTypeWithCharset()
|
||||
{
|
||||
$response = $this->createMock(ResponseInterface::class);
|
||||
|
||||
$response->expects($this->exactly(2))
|
||||
->method('getStatusCode')
|
||||
->willReturn(200);
|
||||
|
||||
$response->expects($this->once())
|
||||
->method('getContent')
|
||||
->willReturn(json_encode(['ok' => true, 'ts' => '1503435956.000247']));
|
||||
|
||||
$client = new MockHttpClient(function (string $method, string $url, array $options = []) use ($response): ResponseInterface {
|
||||
$this->assertContains('Content-Type: application/json; charset=utf-8', $options['headers']);
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
||||
$transport = $this->createTransport($client);
|
||||
|
||||
$transport->send(new ChatMessage('testMessage'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user