diff --git a/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php b/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php index 79cfd1d502917..ef2f68b0fb4c3 100644 --- a/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/RocketChat/RocketChatTransport.php @@ -43,6 +43,10 @@ public function __construct(string $accessToken, string $chatChannel = null, Htt public function __toString(): string { + if (null === $this->chatChannel) { + return sprintf('rocketchat://%s', $this->getEndpoint()); + } + return sprintf('rocketchat://%s?channel=%s', $this->getEndpoint(), $this->chatChannel); } diff --git a/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportTest.php b/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportTest.php index f28e57ff52287..87ec4e563a88e 100644 --- a/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/RocketChat/Tests/RocketChatTransportTest.php @@ -30,6 +30,13 @@ public function testToStringContainsProperties() $this->assertSame('rocketchat://host.test?channel=testChannel', (string) $transport); } + public function testToStringContainsNoChannelBecauseItsOptional() + { + $transport = $this->createTransport(null); + + $this->assertSame('rocketchat://host.test', (string) $transport); + } + public function testSupportsChatMessage() { $transport = $this->createTransport(); @@ -46,8 +53,8 @@ public function testSendNonChatMessageThrowsLogicException() $transport->send($this->createMock(MessageInterface::class)); } - private function createTransport(): RocketChatTransport + private function createTransport(?string $channel = 'testChannel'): RocketChatTransport { - return (new RocketChatTransport('testAccessToken', 'testChannel', $this->createMock(HttpClientInterface::class)))->setHost('host.test'); + return (new RocketChatTransport('testAccessToken', $channel, $this->createMock(HttpClientInterface::class)))->setHost('host.test'); } } diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php index b736cccb54617..c5f8524c84171 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php @@ -48,6 +48,10 @@ public function __construct(string $token, string $channel = null, HttpClientInt public function __toString(): string { + if (null === $this->chatChannel) { + return sprintf('telegram://%s', $this->getEndpoint()); + } + return sprintf('telegram://%s?channel=%s', $this->getEndpoint(), $this->chatChannel); } diff --git a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php index ededeec27fa32..1cd15d2eacb36 100644 --- a/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php +++ b/src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php @@ -31,6 +31,13 @@ public function testToStringContainsProperties() $this->assertSame('telegram://host.test?channel=testChannel', (string) $transport); } + public function testToStringContainsNoChannelBecauseItsOptional() + { + $transport = $this->createTransport(null); + + $this->assertSame('telegram://host.test', (string) $transport); + } + public function testSupportsChatMessage() { $transport = $this->createTransport(); @@ -186,7 +193,7 @@ public function testSendWithChannelOverride() $this->assertEquals('telegram://host.test?channel=defaultChannel', $sentMessage->getTransport()); } - private function createTransport($channel = 'testChannel', ?HttpClientInterface $client = null): TelegramTransport + private function createTransport(?string $channel = 'testChannel', ?HttpClientInterface $client = null): TelegramTransport { return (new TelegramTransport('token', $channel, $client ?: $this->createMock(HttpClientInterface::class)))->setHost('host.test'); } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy