Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit3bd051f

Browse files
committed
bug#49025 [Notifier] [OvhCloud] handle invalid receiver (seferov)
This PR was squashed before being merged into the 5.4 branch.Discussion----------[Notifier] [OvhCloud] handle invalid receiver| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | no| License | MITFix `Undefined offset: 0` error when invalid receiver is providedCommits-------d41f0bf [Notifier] [OvhCloud] handle invalid receiver
2 parentsbf901b8 +d41f0bf commit3bd051f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

‎src/Symfony/Component/Notifier/Bridge/OvhCloud/OvhCloudTransport.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ protected function doSend(MessageInterface $message): SentMessage
121121

122122
$success =$response->toArray(false);
123123

124+
if (!isset($success['ids'][0])) {
125+
thrownewTransportException(sprintf('Attempt to send the SMS to invalid receivers: "%s".',implode(',',$success['invalidReceivers'])),$response);
126+
}
127+
124128
$sentMessage =newSentMessage($message, (string)$this);
125129
$sentMessage->setMessageId($success['ids'][0]);
126130

‎src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportTest.php‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
useSymfony\Component\HttpClient\MockHttpClient;
1515
useSymfony\Component\HttpClient\Response\MockResponse;
1616
useSymfony\Component\Notifier\Bridge\OvhCloud\OvhCloudTransport;
17+
useSymfony\Component\Notifier\Exception\TransportException;
1718
useSymfony\Component\Notifier\Message\ChatMessage;
1819
useSymfony\Component\Notifier\Message\MessageInterface;
1920
useSymfony\Component\Notifier\Message\SmsMessage;
@@ -92,4 +93,26 @@ public function testValidSignature(string $message)
9293
$toSign ='applicationSecret+consumerKey+POST+'.$endpoint.'+'.$body.'+'.$time;
9394
$this->assertSame('$1$'.sha1($toSign),$signature);
9495
}
96+
97+
publicfunctiontestInvalidReceiver()
98+
{
99+
$smsMessage =newSmsMessage('invalid_receiver','lorem ipsum');
100+
101+
$data =json_encode([
102+
'totalCreditsRemoved' =>'1',
103+
'invalidReceivers' => ['invalid_receiver'],
104+
'ids' => [],
105+
'validReceivers' => [],
106+
]);
107+
$responses = [
108+
newMockResponse((string)time()),
109+
newMockResponse($data),
110+
];
111+
112+
$transport =$this->createTransport(newMockHttpClient($responses));
113+
114+
$this->expectException(TransportException::class);
115+
$this->expectExceptionMessage('Attempt to send the SMS to invalid receivers: "invalid_receiver"');
116+
$transport->send($smsMessage);
117+
}
95118
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp