From f5e750003f81704008248d5d752dae38ba339769 Mon Sep 17 00:00:00 2001 From: gnito-org <70450336+gnito-org@users.noreply.github.com> Date: Mon, 5 Dec 2022 14:24:07 -0400 Subject: [PATCH] [Notifier] Add Smsmode bridge --- .../FrameworkExtension.php | 1 + .../Resources/config/notifier_transports.php | 4 + .../Notifier/Bridge/Smsmode/.gitattributes | 4 + .../Notifier/Bridge/Smsmode/.gitignore | 3 + .../Notifier/Bridge/Smsmode/CHANGELOG.md | 7 ++ .../Component/Notifier/Bridge/Smsmode/LICENSE | 19 +++ .../Notifier/Bridge/Smsmode/README.md | 24 ++++ .../Bridge/Smsmode/SmsmodeOptions.php | 85 +++++++++++++ .../Bridge/Smsmode/SmsmodeTransport.php | 113 ++++++++++++++++++ .../Smsmode/SmsmodeTransportFactory.php | 45 +++++++ .../Smsmode/Tests/SmsmodeOptionsTest.php | 29 +++++ .../Tests/SmsmodeTransportFactoryTest.php | 49 ++++++++ .../Smsmode/Tests/SmsmodeTransportTest.php | 111 +++++++++++++++++ .../Notifier/Bridge/Smsmode/composer.json | 36 ++++++ .../Notifier/Bridge/Smsmode/phpunit.xml.dist | 31 +++++ .../Exception/UnsupportedSchemeException.php | 4 + .../UnsupportedSchemeExceptionTest.php | 2 + src/Symfony/Component/Notifier/Transport.php | 1 + 18 files changed, 568 insertions(+) create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/.gitattributes create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/.gitignore create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/CHANGELOG.md create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/LICENSE create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/README.md create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeOptions.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransport.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransportFactory.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeOptionsTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportFactoryTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportTest.php create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/composer.json create mode 100644 src/Symfony/Component/Notifier/Bridge/Smsmode/phpunit.xml.dist diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 3fcfddad0d65c..386cbb449f286 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -2752,6 +2752,7 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $ NotifierBridge\SmsBiuras\SmsBiurasTransportFactory::class => 'notifier.transport_factory.sms-biuras', NotifierBridge\Smsc\SmscTransportFactory::class => 'notifier.transport_factory.smsc', NotifierBridge\SmsFactor\SmsFactorTransportFactory::class => 'notifier.transport_factory.sms-factor', + NotifierBridge\Smsmode\SmsmodeTransportFactory::class => 'notifier.transport_factory.smsmode', NotifierBridge\SpotHit\SpotHitTransportFactory::class => 'notifier.transport_factory.spot-hit', NotifierBridge\Telegram\TelegramTransportFactory::class => 'notifier.transport_factory.telegram', NotifierBridge\Telnyx\TelnyxTransportFactory::class => 'notifier.transport_factory.telnyx', diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php index 746bf94618fff..1573aa0bea0a4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/notifier_transports.php @@ -283,5 +283,9 @@ ->set('notifier.transport_factory.click-send', Bridge\ClickSend\ClickSendTransportFactory::class) ->parent('notifier.transport_factory.abstract') ->tag('texter.transport_factory') + + ->set('notifier.transport_factory.smsmode', Bridge\Smsmode\SmsmodeTransportFactory::class) + ->parent('notifier.transport_factory.abstract') + ->tag('texter.transport_factory') ; }; diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/.gitattributes b/src/Symfony/Component/Notifier/Bridge/Smsmode/.gitattributes new file mode 100644 index 0000000000000..84c7add058fb5 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/.gitattributes @@ -0,0 +1,4 @@ +/Tests export-ignore +/phpunit.xml.dist export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/.gitignore b/src/Symfony/Component/Notifier/Bridge/Smsmode/.gitignore new file mode 100644 index 0000000000000..c49a5d8df5c65 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/CHANGELOG.md b/src/Symfony/Component/Notifier/Bridge/Smsmode/CHANGELOG.md new file mode 100644 index 0000000000000..1f2c8f86cde72 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/CHANGELOG.md @@ -0,0 +1,7 @@ +CHANGELOG +========= + +6.3 +--- + + * Add the bridge diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/LICENSE b/src/Symfony/Component/Notifier/Bridge/Smsmode/LICENSE new file mode 100644 index 0000000000000..733c826ebcd63 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2022-present Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/README.md b/src/Symfony/Component/Notifier/Bridge/Smsmode/README.md new file mode 100644 index 0000000000000..48dc9b39cb41a --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/README.md @@ -0,0 +1,24 @@ +Smsmode Notifier +================ + +Provides [Smsmode](https://www.smsmode.com/) integration for Symfony Notifier. + +DSN example +----------- + +``` +SMSMODE_DSN=smsmode://API_KEY@default?from=FROM +``` + +where: + + - `API_KEY` is your Smsmode API key + - `FROM` is your sender ID + +Resources +--------- + + * [Contributing](https://symfony.com/doc/current/contributing/index.html) + * [Report issues](https://github.com/symfony/symfony/issues) and + [send Pull Requests](https://github.com/symfony/symfony/pulls) + in the [main Symfony repository](https://github.com/symfony/symfony) diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeOptions.php b/src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeOptions.php new file mode 100644 index 0000000000000..519878026b37a --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeOptions.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Smsmode; + +use Symfony\Component\Notifier\Message\MessageOptionsInterface; + +/** + * @author gnito-org + */ +final class SmsmodeOptions implements MessageOptionsInterface +{ + private array $options; + + public function __construct(array $options = []) + { + $this->options = $options; + } + + public function getFrom(): ?string + { + return $this->options['from'] ?? null; + } + + public function getRecipientId(): ?string + { + return $this->options['recipient_id'] ?? null; + } + + public function getRefClient(): ?string + { + return $this->options['ref_client'] ?? null; + } + + public function getSentDate(): ?string + { + return $this->options['sent_date'] ?? null; + } + + public function setFrom(string $from): self + { + $this->options['from'] = $from; + + return $this; + } + + public function setRecipientId(string $id): self + { + $this->options['recipient_id'] = $id; + + return $this; + } + + public function setRefClient(string $refClient): self + { + $this->options['ref_client'] = $refClient; + + return $this; + } + + public function setSentDate(string $sentDate): self + { + $this->options['sent_date'] = $sentDate; + + return $this; + } + + public function toArray(): array + { + $options = $this->options; + if (isset($options['recipient_id'])) { + unset($options['recipient_id']); + } + + return $options; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransport.php b/src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransport.php new file mode 100644 index 0000000000000..d3d20d94ab77c --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransport.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Smsmode; + +use Symfony\Component\Notifier\Exception\InvalidArgumentException; +use Symfony\Component\Notifier\Exception\TransportException; +use Symfony\Component\Notifier\Exception\UnsupportedMessageTypeException; +use Symfony\Component\Notifier\Message\MessageInterface; +use Symfony\Component\Notifier\Message\SentMessage; +use Symfony\Component\Notifier\Message\SmsMessage; +use Symfony\Component\Notifier\Transport\AbstractTransport; +use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface; +use Symfony\Contracts\HttpClient\HttpClientInterface; + +/** + * @author gnito-org + */ +final class SmsmodeTransport extends AbstractTransport +{ + protected const HOST = 'rest.smsmode.com'; + + public function __construct( + #[\SensitiveParameter] private readonly string $apiKey, + private readonly ?string $from = null, + HttpClientInterface $client = null, + EventDispatcherInterface $dispatcher = null + ) { + parent::__construct($client, $dispatcher); + } + + public function __toString(): string + { + $queryParameters = []; + if ($this->from) { + $queryParameters['from'] = $this->from; + } + + return sprintf('smsmode://%s', $this->getEndpoint()).($queryParameters ? '?'.http_build_query($queryParameters) : null); + } + + public function supports(MessageInterface $message): bool + { + return $message instanceof SmsMessage && (null === $message->getOptions() || $message->getOptions() instanceof SmsmodeOptions); + } + + /** + * https://dev.smsmode.com/sms/v1/message. + */ + protected function doSend(MessageInterface $message): SentMessage + { + if (!$message instanceof SmsMessage) { + throw new UnsupportedMessageTypeException(__CLASS__, SmsMessage::class, $message); + } + + $endpoint = sprintf('https://%s/sms/v1/messages', $this->getEndpoint()); + + $opts = $message->getOptions(); + $options = $opts ? $opts->toArray() : []; + $options['body']['text'] = $message->getSubject(); + $options['recipient']['to'] = $message->getPhone(); + + if (!isset($options['from'])) { + $options['from'] = $this->from; + } + + if (!preg_match('/^[a-zA-Z0-9\s]{1,11}$/', $options['from'] ?? '')) { + throw new InvalidArgumentException(sprintf('The "From" value "%s" is not a valid sender ID.', $this->from)); + } + + if (isset($options['sent_date'])) { + $options['sentDate'] = $options['sent_date']; + unset($options['sent_date']); + } + + if (isset($options['ref_client'])) { + $options['refClient'] = $options['ref_client']; + unset($options['ref_client']); + } + + $response = $this->client->request('POST', $endpoint, [ + 'headers' => ['X-Api-Key' => $this->apiKey], + 'json' => array_filter($options), + ]); + + try { + $statusCode = $response->getStatusCode(); + } catch (TransportExceptionInterface $e) { + throw new TransportException('Could not reach the remote Smsmode server.', $response, 0, $e); + } + + if (201 !== $statusCode) { + $error = $response->getContent(false); + throw new TransportException(sprintf('Unable to send the SMS - "%s".', $error ?: 'unknown failure'), $response); + } + + $success = $response->toArray(false); + + $sentMessage = new SentMessage($message, (string) $this); + $sentMessage->setMessageId($success['messageId']); + + return $sentMessage; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransportFactory.php b/src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransportFactory.php new file mode 100644 index 0000000000000..d037a8a37ed00 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/SmsmodeTransportFactory.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Smsmode; + +use Symfony\Component\Notifier\Exception\UnsupportedSchemeException; +use Symfony\Component\Notifier\Transport\AbstractTransportFactory; +use Symfony\Component\Notifier\Transport\Dsn; + +/** + * @author gnito-org + */ +final class SmsmodeTransportFactory extends AbstractTransportFactory +{ + private const TRANSPORT_SCHEME = 'smsmode'; + + public function create(Dsn $dsn): SmsmodeTransport + { + $scheme = $dsn->getScheme(); + + if (self::TRANSPORT_SCHEME !== $scheme) { + throw new UnsupportedSchemeException($dsn, self::TRANSPORT_SCHEME, $this->getSupportedSchemes()); + } + + $apiKey = $this->getUser($dsn); + $from = $dsn->getRequiredOption('from'); + $host = 'default' === $dsn->getHost() ? null : $dsn->getHost(); + $port = $dsn->getPort(); + + return (new SmsmodeTransport($apiKey, $from, $this->client, $this->dispatcher))->setHost($host)->setPort($port); + } + + protected function getSupportedSchemes(): array + { + return [self::TRANSPORT_SCHEME]; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeOptionsTest.php b/src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeOptionsTest.php new file mode 100644 index 0000000000000..93d1ad9d03c9f --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeOptionsTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Smsmode\Tests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Notifier\Bridge\Smsmode\SmsmodeOptions; + +class SmsmodeOptionsTest extends TestCase +{ + public function testSmsmodeOptions() + { + $smsmodeOptions = (new SmsmodeOptions())->setFrom('test_from')->setRecipientId('test_recipient')->setRefClient('test_ref_client')->setSentDate('test_sent_date'); + + self::assertSame([ + 'from' => 'test_from', + 'ref_client' => 'test_ref_client', + 'sent_date' => 'test_sent_date', + ], $smsmodeOptions->toArray()); + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportFactoryTest.php new file mode 100644 index 0000000000000..b5ce68db1ab0d --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportFactoryTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Smsmode\Tests; + +use Symfony\Component\Notifier\Bridge\Smsmode\SmsmodeTransportFactory; +use Symfony\Component\Notifier\Test\TransportFactoryTestCase; + +final class SmsmodeTransportFactoryTest extends TransportFactoryTestCase +{ + public function createFactory(): SmsmodeTransportFactory + { + return new SmsmodeTransportFactory(); + } + + public function createProvider(): iterable + { + yield ['smsmode://host.test?from=test', 'smsmode://ApiKey@host.test?from=test']; + } + + public function incompleteDsnProvider(): iterable + { + yield 'missing API key' => ['smsmode://@default?from=test']; + } + + public function missingRequiredOptionProvider(): iterable + { + yield 'missing option: from' => ['smsmode://apiKey@default']; + } + + public function supportsProvider(): iterable + { + yield [true, 'smsmode://apiKey@default?from=test']; + yield [false, 'somethingElse://apiKey@default?from=test']; + } + + public function unsupportedSchemeProvider(): iterable + { + yield ['somethingElse://apiKey@default?from=test']; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportTest.php b/src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportTest.php new file mode 100644 index 0000000000000..2fb605b84df89 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/Tests/SmsmodeTransportTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\Smsmode\Tests; + +use Symfony\Component\HttpClient\MockHttpClient; +use Symfony\Component\Notifier\Bridge\Smsmode\SmsmodeOptions; +use Symfony\Component\Notifier\Bridge\Smsmode\SmsmodeTransport; +use Symfony\Component\Notifier\Exception\InvalidArgumentException; +use Symfony\Component\Notifier\Message\ChatMessage; +use Symfony\Component\Notifier\Message\MessageInterface; +use Symfony\Component\Notifier\Message\SmsMessage; +use Symfony\Component\Notifier\Test\TransportTestCase; +use Symfony\Contracts\HttpClient\HttpClientInterface; +use Symfony\Contracts\HttpClient\ResponseInterface; + +final class SmsmodeTransportTest extends TransportTestCase +{ + public function createTransport(HttpClientInterface $client = null, string $from = 'test_from'): SmsmodeTransport + { + return new SmsmodeTransport('test_api_key', $from, $client ?? $this->createMock(HttpClientInterface::class)); + } + + public function invalidFromProvider(): iterable + { + yield 'sender number too send' => ['aaaaaaaaaaaa']; + } + + public function supportedMessagesProvider(): iterable + { + yield [new SmsMessage('0611223344', 'Hello!')]; + yield [new SmsMessage('0611223344', 'Hello!', 'from', new SmsmodeOptions(['ref_client' => 'test_ref_client']))]; + } + + /** + * @dataProvider invalidFromProvider + */ + public function testInvalidArgumentExceptionIsThrownIfFromIsInvalid(string $from) + { + $transport = $this->createTransport(null, $from); + + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage(sprintf('The "From" value "%s" is not a valid sender ID.', $from)); + + $transport->send(new SmsMessage('+33612345678', 'Hello!')); + } + + /** + * @dataProvider validFromProvider + */ + public function testNoInvalidArgumentExceptionIsThrownIfFromIsValid(string $from) + { + $message = new SmsMessage('+33612345678', 'Hello!'); + + $response = $this->createMock(ResponseInterface::class); + + $response->expects(self::exactly(2))->method('getStatusCode')->willReturn(201); + + $response->expects(self::once())->method('getContent')->willReturn(json_encode(['messageId' => 'foo'])); + + $client = new MockHttpClient(function (string $method, string $url) use ($response): ResponseInterface { + self::assertSame('POST', $method); + self::assertSame('https://rest.smsmode.com/sms/v1/messages', $url); + + return $response; + }); + + $transport = $this->createTransport($client, $from); + + $sentMessage = $transport->send($message); + + self::assertSame('foo', $sentMessage->getMessageId()); + } + + public function toStringProvider(): iterable + { + yield ['smsmode://rest.smsmode.com?from=test_from', $this->createTransport()]; + } + + public function unsupportedMessagesProvider(): iterable + { + yield [new ChatMessage('Hello!')]; + yield [$this->createMock(MessageInterface::class)]; + } + + public function validFromProvider(): iterable + { + yield ['a']; + yield ['ab']; + yield ['abc']; + yield ['abcd']; + yield ['abcde']; + yield ['abcdef']; + yield ['abcdefg']; + yield ['abcdefgh']; + yield ['abcdefghi']; + yield ['abcdefghij']; + yield ['abcdefghijk']; + yield ['abcdef ghij']; + yield [' abcdefghij']; + yield ['abcdefghij ']; + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/composer.json b/src/Symfony/Component/Notifier/Bridge/Smsmode/composer.json new file mode 100644 index 0000000000000..c86f85cbe8218 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/composer.json @@ -0,0 +1,36 @@ +{ + "name": "symfony/smsmode-notifier", + "type": "symfony-notifier-bridge", + "description": "Symfony Smsmode Notifier Bridge", + "keywords": [ + "smsmode", + "notifier" + ], + "homepage": "https://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "gnito-org", + "homepage": "https://github.com/gnito-org" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "require": { + "php": ">=8.1", + "symfony/http-client": "^5.4|^6.0", + "symfony/notifier": "^6.3" + }, + "require-dev": { + "symfony/event-dispatcher": "^5.4|^6.0" + }, + "autoload": { + "psr-4": {"Symfony\\Component\\Notifier\\Bridge\\Smsmode\\": ""}, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "minimum-stability": "dev" +} diff --git a/src/Symfony/Component/Notifier/Bridge/Smsmode/phpunit.xml.dist b/src/Symfony/Component/Notifier/Bridge/Smsmode/phpunit.xml.dist new file mode 100644 index 0000000000000..16d3aa7a96d74 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/Smsmode/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + diff --git a/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php b/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php index 52abfd0dfb833..b11264ce610cf 100644 --- a/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php +++ b/src/Symfony/Component/Notifier/Exception/UnsupportedSchemeException.php @@ -228,6 +228,10 @@ class UnsupportedSchemeException extends LogicException 'class' => Bridge\SmsFactor\SmsFactorTransportFactory::class, 'package' => 'symfony/sms-factor-notifier', ], + 'smsmode' => [ + 'class' => Bridge\Smsmode\SmsmodeTransportFactory::class, + 'package' => 'symfony/smsmode-notifier', + ], 'sns' => [ 'class' => Bridge\AmazonSns\AmazonSnsTransportFactory::class, 'package' => 'symfony/amazon-sns-notifier', diff --git a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php index 0c8d5dcc3398d..d211d15422e8f 100644 --- a/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php +++ b/src/Symfony/Component/Notifier/Tests/Exception/UnsupportedSchemeExceptionTest.php @@ -79,6 +79,7 @@ public static function setUpBeforeClass(): void Bridge\SmsBiuras\SmsBiurasTransportFactory::class => false, Bridge\Smsc\SmscTransportFactory::class => false, Bridge\SmsFactor\SmsFactorTransportFactory::class => false, + Bridge\Smsmode\SmsmodeTransportFactory::class => false, Bridge\SpotHit\SpotHitTransportFactory::class => false, Bridge\Telegram\TelegramTransportFactory::class => false, Bridge\Telnyx\TelnyxTransportFactory::class => false, @@ -153,6 +154,7 @@ public static function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \ yield ['smsbiuras', 'symfony/sms-biuras-notifier']; yield ['smsc', 'symfony/smsc-notifier']; yield ['sms-factor', 'symfony/sms-factor-notifier']; + yield ['smsmode', 'symfony/smsmode-notifier']; yield ['spothit', 'symfony/spot-hit-notifier']; yield ['telegram', 'symfony/telegram-notifier']; yield ['telnyx', 'symfony/telnyx-notifier']; diff --git a/src/Symfony/Component/Notifier/Transport.php b/src/Symfony/Component/Notifier/Transport.php index 7ef1ac264bd21..db21d16134598 100644 --- a/src/Symfony/Component/Notifier/Transport.php +++ b/src/Symfony/Component/Notifier/Transport.php @@ -81,6 +81,7 @@ final class Transport Bridge\SmsBiuras\SmsBiurasTransportFactory::class, Bridge\Smsc\SmscTransportFactory::class, Bridge\SmsFactor\SmsFactorTransportFactory::class, + Bridge\Smsmode\SmsmodeTransportFactory::class, Bridge\SpotHit\SpotHitTransportFactory::class, Bridge\Telegram\TelegramTransportFactory::class, Bridge\Telnyx\TelnyxTransportFactory::class,