Skip to content

Commit f73b48f

Browse files
Merge branch '6.4' into 7.0
* 6.4: (32 commits) [Validator] Fix registering "is_valid()" for `#[Expression]` [Scheduler] Trigger unique messages at runtime [Scheduler] Fix CHANGELOG [Clock] Add `DatePoint`: an immutable DateTime implementation with stricter error handling and return types [Scheduler] Allow modifying the schedule at runtime and recalculate heap [Cache] Fix Redis6Proxy [Finder] Disable failing test about open_basedir Fix merge Fix merge Minor CS fixes Deprecate `Kernel::stripComments()` Remove setAccessible reflection call in tests [Notifier] Telegram Bridge add escaping for \ [Component][AssertMapper] add type hint of an argument in asset mapper command [Translation] [Phrase] Refacto ReadConfig and WriteConfig into arrays [Routing] Fix routing collection defaults when adding a new route to a collection [Messenger] Fix cloned TraceableStack not unstacking the stack independently [Translation] Add `--as-tree` option to `translation:pull` command [Mime] Allow to add some headers as a strings [Translation] Give current locale to locale switcher runWithLocale callback ...
2 parents 439dd6a + 3305dbe commit f73b48f

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)