Skip to content

[Notifier] [Telegram] Fix version and exception signature #51994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class TelegramTransport extends AbstractTransport
private string $token;
private ?string $chatChannel;

public const EXCLUSIVE_OPTIONS = [
private const EXCLUSIVE_OPTIONS = [
'message_id',
'callback_query_id',
'photo',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,6 @@ public function testUsingMultipleExclusiveOptionsWillProvideExceptions(TelegramO
$transport = self::createTransport($client, 'testChannel');

$this->expectException(MultipleExclusiveOptionsUsedException::class);
$sentMessage = $transport->send(new ChatMessage('', $messageOptions));
$transport->send(new ChatMessage('', $messageOptions));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
],
"require": {
"php": ">=8.1",
"symfony/http-client": "^5.4|^6.0|^7.0",
"symfony/notifier": "^6.2.7|^7.0"
"symfony/http-client": "^6.3|^7.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this bump?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need #49911

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and for this we need symfony/mime also

"symfony/mime": "^5.4|^6.3|^7.0",
"symfony/notifier": "^6.4|^7.0"
},
"autoload": {
"psr-4": { "Symfony\\Component\\Notifier\\Bridge\\Telegram\\": "" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
class MultipleExclusiveOptionsUsedException extends InvalidArgumentException
{
/**
* @param string[] $usedExclusiveOptions
* @param string[]|null $exclusiveOptions
* @param string[] $usedExclusiveOptions
* @param string[] $exclusiveOptions
*/
public function __construct(array $usedExclusiveOptions, array $exclusiveOptions = null, \Throwable $previous = null)
public function __construct(array $usedExclusiveOptions, array $exclusiveOptions, \Throwable $previous = null)
{
$message = sprintf('Multiple exclusive options have been used "%s".', implode('", "', $usedExclusiveOptions));
if (null !== $exclusiveOptions) {
$message .= sprintf(' Only one of %s can be used.', implode('", "', $exclusiveOptions));
}
$message = sprintf(
'Multiple exclusive options have been used "%s". Only one of "%s" can be used.',
implode('", "', $usedExclusiveOptions),
implode('", "', $exclusiveOptions)
);

parent::__construct($message, 0, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Notifier\Tests\Exception;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Exception\MultipleExclusiveOptionsUsedException;

class MultipleExclusiveOptionsUsedExceptionTest extends TestCase
{
public function testMessage()
{
$exception = new MultipleExclusiveOptionsUsedException(['foo', 'bar'], ['foo', 'bar', 'baz']);

$this->assertSame(
'Multiple exclusive options have been used "foo", "bar". Only one of "foo", "bar", "baz" can be used.',
$exception->getMessage()
);
}
}