diff --git a/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportFactoryTest.php b/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportFactoryTest.php new file mode 100644 index 0000000000..c85b7706c4 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportFactoryTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\LightSms\Tests; + +use Symfony\Component\Notifier\Bridge\LightSms\LightSmsTransportFactory; +use Symfony\Component\Notifier\Test\TransportFactoryTestCase; +use Symfony\Component\Notifier\Transport\TransportFactoryInterface; + +final class LightSmsTransportFactoryTest extends TransportFactoryTestCase +{ + /** + * @return LightSmsTransportFactory + */ + public function createFactory(): TransportFactoryInterface + { + return new LightSmsTransportFactory(); + } + + public function createProvider(): iterable + { + yield [ + 'lightsms://host.test?phone=0611223344', + 'lightsms://accountSid:authToken@host.test?phone=0611223344', + ]; + } + + public function supportsProvider(): iterable + { + yield [true, 'lightsms://login:token@default?phone=37061234567']; + yield [false, 'somethingElse://login:token@default?phone=37061234567']; + } + + public function unsupportedSchemeProvider(): iterable + { + yield ['somethingElse://accountSid:authToken@default?from=37061234567']; + yield ['somethingElse://accountSid:authToken@default']; // missing "phone" option + } +} diff --git a/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportTest.php b/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportTest.php new file mode 100644 index 0000000000..2082458d33 --- /dev/null +++ b/src/Symfony/Component/Notifier/Bridge/LightSms/Tests/LightSmsTransportTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Notifier\Bridge\LightSms\Tests; + +use Symfony\Component\Notifier\Bridge\LightSms\LightSmsTransport; +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\Component\Notifier\Transport\TransportInterface; +use Symfony\Contracts\HttpClient\HttpClientInterface; + +final class LightSmsTransportTest extends TransportTestCase +{ + /** + * @return LightSmsTransport + */ + public function createTransport(?HttpClientInterface $client = null): TransportInterface + { + return new LightSmsTransport('accountSid', 'authToken', 'from', $client ?: $this->createMock(HttpClientInterface::class)); + } + + public function toStringProvider(): iterable + { + yield ['lightsms://www.lightsms.com/external/get/send.php?phone=from', $this->createTransport()]; + } + + public function supportedMessagesProvider(): iterable + { + yield [new SmsMessage('0611223344', 'Hello!')]; + } + + public function unsupportedMessagesProvider(): iterable + { + yield [new ChatMessage('Hello!')]; + yield [$this->createMock(MessageInterface::class)]; + } +}