Skip to content

Commit 3305dbe

Browse files
Merge branch '6.3' into 6.4
* 6.3: [Cache] Fix Redis6Proxy [Finder] Disable failing test about open_basedir Fix merge Fix merge [Notifier] Telegram Bridge add escaping for \ [Routing] Fix routing collection defaults when adding a new route to a collection [Messenger] Fix cloned TraceableStack not unstacking the stack independently [DependencyInjection] Fix autocasting null env values to empty string with container.env_var_processors_locator [Cache] Fix support for Redis Sentinel using php-redis 6.0.0 [Notifier] Fix Smsmode HttpClient mandatory headers minor #51693 Disable the dead code analysis in Psalm (stof) Update the PR template [SecurityBundle][PasswordHasher] Fix password migration with custom hasher service with security bundle config [Translator] Fix support for `default_path` in XML [FrameworkBundle] Handle tags array attributes in descriptors [HttpClient] Fix TraceableResponse if response has no destruct method [FrameworkBundle] Always use buildDir as `ConfigBuilderGenerator` outputDir
2 parents 997968c + 2edeecd commit 3305dbe

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

SmsmodeTransport.php

Lines 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

Tests/SmsmodeTransportTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@ public function testNoInvalidArgumentExceptionIsThrownIfFromIsValid(string $from
8080
self::assertSame('foo', $sentMessage->getMessageId());
8181
}
8282

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+
83104
public static function toStringProvider(): iterable
84105
{
85106
yield ['smsmode://rest.smsmode.com?from=test_from', self::createTransport()];

0 commit comments

Comments
 (0)