PushMessage example


        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()];
    }

    public function testSendWithOptions()
    {
        $messageSubject = 'testMessageSubject';
        
public static function supportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('+48123123123', 'Summary')];
        yield [new SmsMessage('+48123123123', 'Summary', '')];
        yield [new SmsMessage('+48123123123', 'Summary', 'customSender')];
        yield [new SmsMessage('+48123123123', 'Summary', '', (new RedlinkOptions())->externalId('aaa-aaa-aaa'))];
    }

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new PushMessage('Hi!', 'Hello!')];
        yield [new ChatMessage('Hello!')];
        yield [new DummyMessage()];
    }
}

        return new ExpoTransport('token', $client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['expo://exp.host/--/api/v2/push/send', self::createTransport()];
    }

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

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

        return (new NovuTransport('9c9ced75881ddc65c033273f466b42d1', $client ?? new MockHttpClient()))->setHost('host.test');
    }

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

    public static function supportedMessagesProvider(): iterable
    {
        yield [new PushMessage('test', '{}', new NovuOptions(123, null, null, 'test@example.com', null, null, null, []))];
    }

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

    public function testWithErrorResponseThrows()
    {
        $response = $this->createMock(ResponseInterface::class);
        

        return (new PagerDutyTransport('testToken', $client ?? new MockHttpClient()))->setHost('test.pagerduty.com');
    }

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

    public static function supportedMessagesProvider(): iterable
    {
        yield [new PushMessage('Source', 'Summary')];
        yield [new PushMessage('Source', 'Summary', new PagerDutyOptions('e93facc04764012d7bfb002500d5d1a6', 'trigger', 'info'))];
        yield [new PushMessage('Source', 'Summary', new PagerDutyOptions('e93facc04764012d7bfb002500d5d1a6', 'acknowledge', 'info', ['dedup_key' => 'srv01/test']))];
    }

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

        return new NtfyTransport('test', true, $client ?? new MockHttpClient());
    }

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

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

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

    public function testCanSetCustomHost()
    {
        $transport = $this->createTransport();
        
use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Message\PushMessage;
use Symfony\Component\Notifier\Notification\Notification;

/** * @author Tomas Norkūnas <norkunas.tom@gmail.com> */
class PushMessageTest extends TestCase
{
    public function testCanBeConstructed()
    {
        $message = new PushMessage('Hello', 'World');

        $this->assertSame('Hello', $message->getSubject());
        $this->assertSame('World', $message->getContent());
    }

    public function testSetSubject()
    {
        $message = new PushMessage('Hello', 'World');
        $message->subject('dlrow olleH');

        $this->assertSame('dlrow olleH', $message->getSubject());
    }

        return new EngagespotTransport('apiKey', 'TEST', $client ?? new MockHttpClient());
    }

    public static function toStringProvider(): iterable
    {
        yield ['engagespot://api.engagespot.co/2/campaigns?campaign_name=TEST', self::createTransport()];
    }

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

    public static function unsupportedMessagesProvider(): iterable
    {
        yield [new SmsMessage('0123456789', 'Hello!')];
        yield [new DummyMessage()];
    }
}
$this->assertSame(sprintf('onesignal://9fb175f0-0b32-4e99-ae97-bd228b9eb246@%s:%d', $customHost$customPort)(string) $transport);
    }

    public static function toStringProvider(): iterable
    {
        yield ['onesignal://9fb175f0-0b32-4e99-ae97-bd228b9eb246@onesignal.com', self::createTransport()];
        yield ['onesignal://9fb175f0-0b32-4e99-ae97-bd228b9eb246@onesignal.com?recipientId=ea345989-d273-4f21-a33b-0c006efc5edb', self::createTransport(null, 'ea345989-d273-4f21-a33b-0c006efc5edb')];
    }

    public static function supportedMessagesProvider(): iterable
    {
        yield [new PushMessage('Hello', 'World'), self::createTransport(null, 'ea345989-d273-4f21-a33b-0c006efc5edb')];
        yield [new PushMessage('Hello', 'World', (new OneSignalOptions())->recipient('ea345989-d273-4f21-a33b-0c006efc5edb'))];
    }

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

    public function testSendThrowsWithoutRecipient()
    {
Home | Imprint | This part of the site doesn't use cookies.