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 3f6d50f

Browse filesBrowse files
committed
bug #48262 [Notifier] [SMSBiuras] true/false mismatch for test_mode option (StaffNowa)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Notifier] [SMSBiuras] `true`/`false` mismatch for `test_mode` option | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Moved from LightSMS service into SMSBiuras and found an issue. SMSBIURAS_DSN=smsbiuras://UID:API_KEY@default?from=FROM&test_mode=0 Documentation is good but in the code bug. If test_mode = 0 - does not send SMS. If test_mode = 1 - sends SMS. Boolean true | false mismatch. SMSBiuras API documentation https://docs.smsbiuras.lt/ Commits ------- cd7e4d6 [Notifier] [SMSBiuras] `true`/`false` mismatch for `test_mode` option
2 parents dd304b3 + cd7e4d6 commit 3f6d50f
Copy full SHA for 3f6d50f

File tree

2 files changed

+79
-1
lines changed
Filter options

2 files changed

+79
-1
lines changed

‎src/Symfony/Component/Notifier/Bridge/SmsBiuras/SmsBiurasTransport.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/SmsBiuras/SmsBiurasTransport.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function doSend(MessageInterface $message): SentMessage
8585
'apikey' => $this->apiKey,
8686
'message' => $message->getSubject(),
8787
'from' => $this->from,
88-
'test' => $this->testMode ? 0 : 1,
88+
'test' => $this->testMode ? 1 : 0,
8989
'to' => $message->getPhone(),
9090
],
9191
]);

‎src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Notifier/Bridge/SmsBiuras/Tests/SmsBiurasTransportTest.php
+78Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
namespace Symfony\Component\Notifier\Bridge\SmsBiuras\Tests;
1313

14+
use Symfony\Component\HttpClient\MockHttpClient;
1415
use Symfony\Component\Notifier\Bridge\SmsBiuras\SmsBiurasTransport;
1516
use Symfony\Component\Notifier\Message\ChatMessage;
1617
use Symfony\Component\Notifier\Message\MessageInterface;
1718
use Symfony\Component\Notifier\Message\SmsMessage;
1819
use Symfony\Component\Notifier\Test\TransportTestCase;
1920
use Symfony\Component\Notifier\Transport\TransportInterface;
2021
use Symfony\Contracts\HttpClient\HttpClientInterface;
22+
use Symfony\Contracts\HttpClient\ResponseInterface;
2123

2224
final class SmsBiurasTransportTest extends TransportTestCase
2325
{
@@ -44,4 +46,80 @@ public function unsupportedMessagesProvider(): iterable
4446
yield [new ChatMessage('Hello!')];
4547
yield [$this->createMock(MessageInterface::class)];
4648
}
49+
50+
/**
51+
* @dataProvider provideTestMode()
52+
*/
53+
public function testTestMode(array $expected, array $provided)
54+
{
55+
$message = new SmsMessage($provided['phone'], $provided['message']);
56+
57+
$response = $this->createMock(ResponseInterface::class);
58+
$response->expects($this->atLeast(1))
59+
->method('getStatusCode')
60+
->willReturn(200);
61+
$response->expects($this->atLeast(1))
62+
->method('getContent')
63+
->willReturn('OK: 519545');
64+
65+
$client = new MockHttpClient(function (string $method, string $url, array $options = []) use ($response, $expected): ResponseInterface {
66+
$this->assertSame('GET', $method);
67+
$this->assertSame(sprintf(
68+
'https://savitarna.smsbiuras.lt/api?uid=uid&apikey=api_key&message=%s&from=from&test=%s&to=%s',
69+
rawurlencode($expected['message']),
70+
$expected['transport']['test_mode'],
71+
rawurlencode($expected['phone']),
72+
), $url);
73+
$this->assertSame($expected['transport']['test_mode'], $options['query']['test']);
74+
75+
$this->assertSame(200, $response->getStatusCode());
76+
$this->assertSame('OK: 519545', $response->getContent());
77+
78+
return $response;
79+
});
80+
81+
$transport = new SmsBiurasTransport('uid', 'api_key', 'from', $provided['transport']['test_mode'], $client);
82+
83+
$sentMessage = $transport->send($message);
84+
85+
$this->assertSame('519545', $sentMessage->getMessageId());
86+
}
87+
88+
public static function provideTestMode(): array
89+
{
90+
return [
91+
[
92+
[
93+
'phone' => '+37012345678',
94+
'message' => 'Hello world!',
95+
'transport' => [
96+
'test_mode' => 0,
97+
],
98+
],
99+
[
100+
'phone' => '+37012345678',
101+
'message' => 'Hello world!',
102+
'transport' => [
103+
'test_mode' => 0,
104+
],
105+
],
106+
],
107+
[
108+
[
109+
'phone' => '+37012345678',
110+
'message' => 'Hello world!',
111+
'transport' => [
112+
'test_mode' => 1,
113+
],
114+
],
115+
[
116+
'phone' => '+37012345678',
117+
'message' => 'Hello world!',
118+
'transport' => [
119+
'test_mode' => 1,
120+
],
121+
],
122+
],
123+
];
124+
}
47125
}

0 commit comments

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