createTransport example

use Symfony\Contracts\HttpClient\HttpClientInterface;

final class TelnyxTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): TelnyxTransport
    {
        return new TelnyxTransport('api_key', 'from', 'messaging_profile_id', $client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['telnyx://api.telnyx.com?from=from&messaging_profile_id=messaging_profile_id', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('+0611223344', 'Hello!')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        yield [new DummyMessage()];
    }
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class ZendeskTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): ZendeskTransport
    {
        return (new ZendeskTransport('testEmail', 'testToken', $client ?? new MockHttpClient()))->setHost('test.zendesk.com');
    }

    public static function toStringProvider(): iterable
    {
        yield ['zendesk://test.zendesk.com', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        yield [new ChatMessage('Hello!', new ZendeskOptions('urgent'))];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
    }
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class SpotHitTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): SpotHitTransport
    {
        return (new SpotHitTransport('api_token', 'MyCompany', $client ?? new MockHttpClient()))->setHost('host.test');
    }

    public static function toStringProvider(): iterable
    {
        yield ['spothit://host.test?from=MyCompany', self::createTransport()];
        yield ['spothit://host.test?from=MyCompany&smslong=1', self::createTransport()->setSmsLong(true)];
        yield ['spothit://host.test?from=MyCompany&smslongnbr=3', self::createTransport()->setLongNBr(3)];
        yield ['spothit://host.test?from=MyCompany&smslong=1&smslongnbr=3', self::createTransport()->setSmsLong(true)->setLongNBr(3)];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
        yield [new SmsMessage('+33611223344', 'Hello!')];
    }

    
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class IqsmsTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): IqsmsTransport
    {
        return new IqsmsTransport('login', 'password', 'sender', $client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['iqsms://api.iqsms.ru?from=sender', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        yield [new DummyMessage()];
    }
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class SendberryTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): SendberryTransport
    {
        return new SendberryTransport('username', 'password', 'auth_key', 'from', $client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['sendberry://api.sendberry.com?from=from', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('+0611223344', 'Hello!')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        yield [new DummyMessage()];
    }
use Symfony\Contracts\HttpClient\ResponseInterface;

final class MessageMediaTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null, string $from = null): MessageMediaTransport
    {
        return new MessageMediaTransport('apiKey', 'apiSecret', $from$client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['messagemedia://api.messagemedia.com', self::createTransport()];
        yield ['messagemedia://api.messagemedia.com?from=TEST', self::createTransport(null, 'TEST')];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0491570156', 'Hello!')];
        yield [new SmsMessage('0491570156', 'Hello!', 'from', new MessageMediaOptions(['from' => 'foo']))];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        
$transport = (new FakeSmsEmailTransport(new DummyMailer(), 'recipient@email.net', 'sender@email.net', $client ?? new MockHttpClient()));

        if (null !== $transportName) {
            $transport->setHost($transportName);
        }

        return $transport;
    }

    public static function toStringProvider(): iterable
    {
        yield ['fakesms+email://default?to=recipient@email.net&from=sender@email.net', self::createTransport()];
        yield ['fakesms+email://mailchimp?to=recipient@email.net&from=sender@email.net', self::createTransport(null, 'mailchimp')];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
        yield [new SmsMessage('+33611223344', 'Hello!')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class MailjetTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): MailjetTransport
    {
        return (new MailjetTransport('authtoken', 'Mailjet', $client ?? new MockHttpClient()))->setHost('host.test');
    }

    public static function toStringProvider(): iterable
    {
        yield ['mailjet://Mailjet@host.test', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        yield [new DummyMessage()];
    }
use Symfony\Contracts\HttpClient\ResponseInterface;

final class BrevoTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): BrevoTransport
    {
        return (new BrevoTransport('api-key', '0611223344', $client ?? new MockHttpClient()))->setHost('host.test');
    }

    public static function toStringProvider(): iterable
    {
        yield ['brevo://host.test?sender=0611223344', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        yield [new DummyMessage()];
    }
use Symfony\Contracts\HttpClient\ResponseInterface;

final class TelegramTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null, string $channel = null): TelegramTransport
    {
        return new TelegramTransport('token', $channel$client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['telegram://api.telegram.org', self::createTransport()];
        yield ['telegram://api.telegram.org?channel=testChannel', self::createTransport(null, 'testChannel')];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
        

final class GitterTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): GitterTransport
    {
        return (new GitterTransport('token', '5539a3ee5etest0d3255bfef', $client ?? new MockHttpClient()))->setHost('api.gitter.im');
    }

    public static function toStringProvider(): iterable
    {
        yield ['gitter://api.gitter.im?room_id=5539a3ee5etest0d3255bfef', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
        yield [new DummyMessage()];
    }
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class Sms77TransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null, string $from = null): Sms77Transport
    {
        return new Sms77Transport('apiKey', $from$client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['sms77://gateway.sms77.io', self::createTransport()];
        yield ['sms77://gateway.sms77.io?from=TEST', self::createTransport(null, 'TEST')];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0611223344', 'Hello!')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        

    public function testSupports(string $dsn, bool $expected = true)
    {
        $this->assertSame($expected$this->factory->supports($dsn[]), 'InMemoryTransportFactory::supports returned unexpected result.');
    }

    public function testCreateTransport()
    {
        /** @var SerializerInterface $serializer */
        $serializer = $this->createMock(SerializerInterface::class);

        $this->assertInstanceOf(InMemoryTransport::class$this->factory->createTransport('in-memory://', []$serializer));
    }

    public function testCreateTransportWithoutSerializer()
    {
        /** @var SerializerInterface $serializer */
        $serializer = $this->createMock(SerializerInterface::class);
        $serializer
            ->expects($this->never())
            ->method('encode')
        ;
        $transport = $this->factory->createTransport('in-memory://?serialize=false', []$serializer);
        
use Symfony\Contracts\HttpClient\ResponseInterface;

final class PushoverTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): PushoverTransport
    {
        return new PushoverTransport('userKey', 'appToken', $client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['pushover://api.pushover.net', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new PushMessage('Hello!', 'World')];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new ChatMessage('Hello!')];
        yield [new DummyMessage()];
    }
use Symfony\Contracts\HttpClient\HttpClientInterface;

class AmazonSnsTransportTest extends TransportTestCase
{
    public static function createTransport(HttpClientInterface $client = null): AmazonSnsTransport
    {
        return (new AmazonSnsTransport(new SnsClient(['region' => 'eu-west-3'])$client ?? new MockHttpClient()))->setHost('host.test');
    }

    public static function toStringProvider(): iterable
    {
        yield ['sns://host.test?region=eu-west-3', self::createTransport()];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0601020304', 'Hello!')];
        yield [new ChatMessage('Hello', new AmazonSnsOptions('my-topic'))];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new DummyMessage()];
        
Home | Imprint | This part of the site doesn't use cookies.