Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 904b05a

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: [Notifier] Improve tests (5.1) [Notifier] Fix wrong package names [Notifier] [Free Mobile] Could not use custom host in DSN
2 parents 6112be3 + 40672e1 commit 904b05a

17 files changed

+59
-76
lines changed

src/Symfony/Component/Notifier/Bridge/Firebase/Tests/FirebaseTransportFactoryTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public function testCreateWithDsn()
2525
{
2626
$factory = $this->createFactory();
2727

28-
$transport = $factory->create(Dsn::fromString('firebase://username:password@default'));
29-
$transport->setHost('host.test');
28+
$transport = $factory->create(Dsn::fromString('firebase://username:[email protected]'));
3029

3130
$this->assertSame('firebase://host.test', (string) $transport);
3231
}

src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransport.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
final class FreeMobileTransport extends AbstractTransport
2929
{
30-
protected const HOST = 'https://smsapi.free-mobile.fr/sendmsg';
30+
protected const HOST = 'smsapi.free-mobile.fr/sendmsg';
3131

3232
private $login;
3333
private $password;
@@ -58,7 +58,9 @@ protected function doSend(MessageInterface $message): SentMessage
5858
throw new LogicException(sprintf('The "%s" transport only supports instances of "%s" (instance of "%s" given) and configured with your phone number.', __CLASS__, SmsMessage::class, \get_class($message)));
5959
}
6060

61-
$response = $this->client->request('POST', $this->getEndpoint(), [
61+
$endpoint = sprintf('https://%s', $this->getEndpoint());
62+
63+
$response = $this->client->request('POST', $endpoint, [
6264
'json' => [
6365
'user' => $this->login,
6466
'pass' => $this->password,

src/Symfony/Component/Notifier/Bridge/FreeMobile/FreeMobileTransportFactory.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ public function create(Dsn $dsn): TransportInterface
4343
throw new IncompleteDsnException('Missing phone.', $dsn->getOriginalDsn());
4444
}
4545

46-
return new FreeMobileTransport($login, $password, $phone, $this->client, $this->dispatcher);
46+
$host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
47+
$port = $dsn->getPort();
48+
49+
return (new FreeMobileTransport($login, $password, $phone, $this->client, $this->dispatcher))->setHost($host)->setPort($port);
4750
}
4851

4952
protected function getSupportedSchemes(): array

src/Symfony/Component/Notifier/Bridge/FreeMobile/Tests/FreeMobileTransportFactoryTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public function testCreateWithDsn()
2323
{
2424
$factory = $this->createFactory();
2525

26-
$dsn = 'freemobile://login:pass@default?phone=0611223344';
27-
$transport = $factory->create(Dsn::fromString($dsn));
28-
$transport->setHost('host.test');
26+
$transport = $factory->create(Dsn::fromString('freemobile://login:[email protected]?phone=0611223344'));
2927

3028
$this->assertSame('freemobile://host.test?phone=0611223344', (string) $transport);
3129
}

src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportFactoryTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ public function testCreateWithDsn()
2626
{
2727
$factory = $this->createFactory();
2828

29-
$accessToken = 'testAccessToken';
30-
$host = 'testHost';
31-
$channel = 'testChannel';
29+
$transport = $factory->create(Dsn::fromString('mattermost://[email protected]?channel=testChannel'));
3230

33-
$transport = $factory->create(Dsn::fromString(sprintf('mattermost://%s@%s/?channel=%s', $accessToken, $host, $channel)));
34-
35-
$this->assertSame(sprintf('mattermost://%s?channel=%s', $host, $channel), (string) $transport);
31+
$this->assertSame('mattermost://host.test?channel=testChannel', (string) $transport);
3632
}
3733

3834
public function testCreateWithMissingOptionChannelThrowsIncompleteDsnException()
@@ -49,21 +45,21 @@ public function testCreateWithNoTokenThrowsIncompleteDsnException()
4945
$factory = $this->createFactory();
5046

5147
$this->expectException(IncompleteDsnException::class);
52-
$factory->create(Dsn::fromString(sprintf('mattermost://%s/?channel=%s', 'testHost', 'testChannel')));
48+
$factory->create(Dsn::fromString('mattermost://host.test?channel=testChannel'));
5349
}
5450

5551
public function testSupportsReturnsTrueWithSupportedScheme()
5652
{
5753
$factory = $this->createFactory();
5854

59-
$this->assertTrue($factory->supports(Dsn::fromString('mattermost://token@host/?channel=testChannel')));
55+
$this->assertTrue($factory->supports(Dsn::fromString('mattermost://token@host?channel=testChannel')));
6056
}
6157

6258
public function testSupportsReturnsFalseWithUnsupportedScheme()
6359
{
6460
$factory = $this->createFactory();
6561

66-
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://token@host/?channel=testChannel')));
62+
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://token@host?channel=testChannel')));
6763
}
6864

6965
public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
@@ -72,7 +68,7 @@ public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
7268

7369
$this->expectException(UnsupportedSchemeException::class);
7470

75-
$factory->create(Dsn::fromString('somethingElse://token@host/?channel=testChannel'));
71+
$factory->create(Dsn::fromString('somethingElse://token@host?channel=testChannel'));
7672
}
7773

7874
public function testUnsupportedSchemeThrowsUnsupportedSchemeExceptionEvenIfRequiredOptionIsMissing()

src/Symfony/Component/Notifier/Bridge/Mattermost/Tests/MattermostTransportTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testSupportsChatMessage()
3838
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
3939
}
4040

41-
public function testSendNonChatMessageThrows()
41+
public function testSendNonChatMessageThrowsLogicException()
4242
{
4343
$transport = $this->createTransport();
4444

src/Symfony/Component/Notifier/Bridge/Nexmo/Tests/NexmoTransportFactoryTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public function testCreateWithDsn()
2323
{
2424
$factory = $this->createFactory();
2525

26-
$dsn = 'nexmo://apiKey:apiSecret@default?from=0611223344';
27-
$transport = $factory->create(Dsn::fromString($dsn));
28-
$transport->setHost('host.test');
26+
$transport = $factory->create(Dsn::fromString('nexmo://apiKey:[email protected]?from=0611223344'));
2927

3028
$this->assertSame('nexmo://host.test?from=0611223344', (string) $transport);
3129
}

src/Symfony/Component/Notifier/Bridge/OvhCloud/Tests/OvhCloudTransportFactoryTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ public function testCreateWithDsn()
2323
{
2424
$factory = $this->createFactory();
2525

26-
$dsn = 'ovhcloud://applicationKey:applicationSecret@default?consumer_key=consumerKey&service_name=serviceName';
27-
$transport = $factory->create(Dsn::fromString($dsn));
28-
$transport->setHost('host.test');
26+
$transport = $factory->create(Dsn::fromString('ovhcloud://applicationKey:[email protected]?consumer_key=consumerKey&service_name=serviceName'));
2927

3028
$this->assertSame('ovhcloud://host.test?consumer_key=consumerKey&service_name=serviceName', (string) $transport);
3129
}

src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportFactoryTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,31 @@ public function testCreateWithDsn()
2626
{
2727
$factory = $this->createFactory();
2828

29-
$accessToken = 'testAccessToken';
30-
$host = 'testHost';
31-
$channel = 'testChannel';
29+
$transport = $factory->create(Dsn::fromString('rocketchat://[email protected]?channel=testChannel'));
3230

33-
$transport = $factory->create(Dsn::fromString(sprintf('rocketchat://%s@%s/?channel=%s', $accessToken, $host, $channel)));
34-
35-
$this->assertSame(sprintf('rocketchat://%s?channel=%s', $host, $channel), (string) $transport);
31+
$this->assertSame('rocketchat://host.test?channel=testChannel', (string) $transport);
3632
}
3733

3834
public function testCreateWithNoTokenThrowsIncompleteDsnException()
3935
{
4036
$factory = $this->createFactory();
4137

4238
$this->expectException(IncompleteDsnException::class);
43-
$factory->create(Dsn::fromString(sprintf('rocketchat://%s/?channel=%s', 'testHost', 'testChannel')));
39+
$factory->create(Dsn::fromString('rocketchat://host.test?channel=testChannel'));
4440
}
4541

4642
public function testSupportsReturnsTrueWithSupportedScheme()
4743
{
4844
$factory = $this->createFactory();
4945

50-
$this->assertTrue($factory->supports(Dsn::fromString('rocketchat://token@host/?channel=testChannel')));
46+
$this->assertTrue($factory->supports(Dsn::fromString('rocketchat://token@host?channel=testChannel')));
5147
}
5248

5349
public function testSupportsReturnsFalseWithUnsupportedScheme()
5450
{
5551
$factory = $this->createFactory();
5652

57-
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://token@host/?channel=testChannel')));
53+
$this->assertFalse($factory->supports(Dsn::fromString('somethingElse://token@host?channel=testChannel')));
5854
}
5955

6056
public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
@@ -63,7 +59,7 @@ public function testUnsupportedSchemeThrowsUnsupportedSchemeException()
6359

6460
$this->expectException(UnsupportedSchemeException::class);
6561

66-
$factory->create(Dsn::fromString('somethingElse://token@host/?channel=testChannel'));
62+
$factory->create(Dsn::fromString('somethingElse://token@host?channel=testChannel'));
6763
}
6864

6965
private function createFactory(): RocketChatTransportFactory

src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testSupportsChatMessage()
3838
$this->assertFalse($transport->supports($this->createMock(MessageInterface::class)));
3939
}
4040

41-
public function testSendNonChatMessageThrows()
41+
public function testSendNonChatMessageThrowsLogicException()
4242
{
4343
$transport = $this->createTransport();
4444

0 commit comments

Comments
 (0)