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

Skip to content

Commit 74e0c9c

Browse files
OskarStarknicolas-grekas
authored andcommitted
[Notifier] [Telegram] Fix version and exception signature
1 parent 6ef211d commit 74e0c9c

File tree

5 files changed

+41
-11
lines changed

5 files changed

+41
-11
lines changed

src/Symfony/Component/Notifier/Bridge/Telegram/TelegramTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class TelegramTransport extends AbstractTransport
3636
private string $token;
3737
private ?string $chatChannel;
3838

39-
public const EXCLUSIVE_OPTIONS = [
39+
private const EXCLUSIVE_OPTIONS = [
4040
'message_id',
4141
'callback_query_id',
4242
'photo',

src/Symfony/Component/Notifier/Bridge/Telegram/Tests/TelegramTransportTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,6 @@ public function testUsingMultipleExclusiveOptionsWillProvideExceptions(TelegramO
12421242
$transport = self::createTransport($client, 'testChannel');
12431243

12441244
$this->expectException(MultipleExclusiveOptionsUsedException::class);
1245-
$sentMessage = $transport->send(new ChatMessage('', $messageOptions));
1245+
$transport->send(new ChatMessage('', $messageOptions));
12461246
}
12471247
}

src/Symfony/Component/Notifier/Bridge/Telegram/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
],
1818
"require": {
1919
"php": ">=8.1",
20-
"symfony/http-client": "^5.4|^6.0|^7.0",
21-
"symfony/notifier": "^6.2.7|^7.0"
20+
"symfony/http-client": "^6.3|^7.0",
21+
"symfony/mime": "^5.4|^6.3|^7.0",
22+
"symfony/notifier": "^6.4|^7.0"
2223
},
2324
"autoload": {
2425
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Telegram\\": "" },

src/Symfony/Component/Notifier/Exception/MultipleExclusiveOptionsUsedException.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
class MultipleExclusiveOptionsUsedException extends InvalidArgumentException
1818
{
1919
/**
20-
* @param string[] $usedExclusiveOptions
21-
* @param string[]|null $exclusiveOptions
20+
* @param string[] $usedExclusiveOptions
21+
* @param string[] $exclusiveOptions
2222
*/
23-
public function __construct(array $usedExclusiveOptions, array $exclusiveOptions = null, \Throwable $previous = null)
23+
public function __construct(array $usedExclusiveOptions, array $exclusiveOptions, \Throwable $previous = null)
2424
{
25-
$message = sprintf('Multiple exclusive options have been used "%s".', implode('", "', $usedExclusiveOptions));
26-
if (null !== $exclusiveOptions) {
27-
$message .= sprintf(' Only one of %s can be used.', implode('", "', $exclusiveOptions));
28-
}
25+
$message = sprintf(
26+
'Multiple exclusive options have been used "%s". Only one of "%s" can be used.',
27+
implode('", "', $usedExclusiveOptions),
28+
implode('", "', $exclusiveOptions)
29+
);
2930

3031
parent::__construct($message, 0, $previous);
3132
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Tests\Exception;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Notifier\Exception\MultipleExclusiveOptionsUsedException;
16+
17+
class MultipleExclusiveOptionsUsedExceptionTest extends TestCase
18+
{
19+
public function testMessage()
20+
{
21+
$exception = new MultipleExclusiveOptionsUsedException(['foo', 'bar'], ['foo', 'bar', 'baz']);
22+
23+
$this->assertSame(
24+
'Multiple exclusive options have been used "foo", "bar". Only one of "foo", "bar", "baz" can be used.',
25+
$exception->getMessage()
26+
);
27+
}
28+
}

0 commit comments

Comments
 (0)