Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a3dd8dc

Browse filesBrowse files
inwebonicolas-grekas
authored andcommitted
[Notifier] Fix Smsmode HttpClient mandatory headers
1 parent 49d2527 commit a3dd8dc
Copy full SHA for a3dd8dc

File tree

Expand file treeCollapse file tree

2 files changed

+25
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+25
-2
lines changed

‎src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransport.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ protected function doSend(MessageInterface $message): SentMessage
6969
}
7070

7171
$response = $this->client->request('POST', $endpoint, [
72-
'headers' => ['X-Api-Key' => $this->apiKey],
72+
'headers' => [
73+
'X-Api-Key' => $this->apiKey,
74+
'Accept' => 'application/json',
75+
],
7376
'json' => array_filter($options),
7477
]);
7578

‎src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportTest.php
+21-1Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Symfony\Component\Notifier\Bridge\Smsmode\SmsmodeTransport;
1717
use Symfony\Component\Notifier\Exception\InvalidArgumentException;
1818
use Symfony\Component\Notifier\Message\ChatMessage;
19-
use Symfony\Component\Notifier\Message\MessageInterface;
2019
use Symfony\Component\Notifier\Message\SmsMessage;
2120
use Symfony\Component\Notifier\Test\TransportTestCase;
2221
use Symfony\Component\Notifier\Tests\Transport\DummyMessage;
@@ -81,6 +80,27 @@ public function testNoInvalidArgumentExceptionIsThrownIfFromIsValid(string $from
8180
self::assertSame('foo', $sentMessage->getMessageId());
8281
}
8382

83+
public function testHttpClientHasMandatoryHeaderAccept()
84+
{
85+
$message = new SmsMessage('+33612345678', 'Hello!');
86+
87+
$response = $this->createMock(ResponseInterface::class);
88+
$response->expects(self::exactly(2))->method('getStatusCode')->willReturn(201);
89+
$response->expects(self::once())->method('getContent')->willReturn(json_encode(['messageId' => 'foo']));
90+
91+
$transport = $this->createTransport(new MockHttpClient(function (string $method, string $url, array $options) use ($response): ResponseInterface {
92+
$this->assertSame('POST', $method);
93+
$this->assertSame('https://rest.smsmode.com/sms/v1/messages', $url);
94+
$this->assertSame('Accept: application/json', $options['normalized_headers']['accept'][0]);
95+
96+
return $response;
97+
}), 'foo');
98+
99+
$result = $transport->send($message);
100+
101+
$this->assertSame('foo', $result->getMessageId());
102+
}
103+
84104
public static function toStringProvider(): iterable
85105
{
86106
yield ['smsmode://rest.smsmode.com?from=test_from', self::createTransport()];

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.