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 bd9cfda

Browse filesBrowse files
committed
minor #48278 [Notifier] [SmsBiuras] Simplify test and data provider (OskarStark)
This PR was merged into the 5.4 branch. Discussion ---------- [Notifier] [SmsBiuras] Simplify test and data provider | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | License | MIT | Doc PR | Follows * #48262 Commits ------- 9221451 [Notifier][SmsBiuras] Simplify test and data provider
2 parents 3f6d50f + 9221451 commit bd9cfda
Copy full SHA for bd9cfda

File tree

1 file changed

+11
-43
lines changed
Filter options

1 file changed

+11
-43
lines changed

‎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
+11-43Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ public function unsupportedMessagesProvider(): iterable
5050
/**
5151
* @dataProvider provideTestMode()
5252
*/
53-
public function testTestMode(array $expected, array $provided)
53+
public function testTestMode(int $expected, bool $testMode)
5454
{
55-
$message = new SmsMessage($provided['phone'], $provided['message']);
55+
$message = new SmsMessage('+37012345678', 'Hello World!');
5656

5757
$response = $this->createMock(ResponseInterface::class);
5858
$response->expects($this->atLeast(1))
@@ -62,64 +62,32 @@ public function testTestMode(array $expected, array $provided)
6262
->method('getContent')
6363
->willReturn('OK: 519545');
6464

65-
$client = new MockHttpClient(function (string $method, string $url, array $options = []) use ($response, $expected): ResponseInterface {
65+
$client = new MockHttpClient(function (string $method, string $url, array $options = []) use ($response, $message, $testMode, $expected): ResponseInterface {
6666
$this->assertSame('GET', $method);
6767
$this->assertSame(sprintf(
6868
'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']),
69+
rawurlencode($message->getSubject()),
70+
$expected,
71+
rawurlencode($message->getPhone()),
7272
), $url);
73-
$this->assertSame($expected['transport']['test_mode'], $options['query']['test']);
73+
$this->assertSame($expected, $options['query']['test']);
7474

7575
$this->assertSame(200, $response->getStatusCode());
7676
$this->assertSame('OK: 519545', $response->getContent());
7777

7878
return $response;
7979
});
8080

81-
$transport = new SmsBiurasTransport('uid', 'api_key', 'from', $provided['transport']['test_mode'], $client);
81+
$transport = new SmsBiurasTransport('uid', 'api_key', 'from', $testMode, $client);
8282

8383
$sentMessage = $transport->send($message);
8484

8585
$this->assertSame('519545', $sentMessage->getMessageId());
8686
}
8787

88-
public static function provideTestMode(): array
88+
public static function provideTestMode(): iterable
8989
{
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-
];
90+
yield [1, true];
91+
yield [0, false];
12492
}
12593
}

0 commit comments

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