OneSignalOptions example



namespace Symfony\Component\Notifier\Bridge\OneSignal\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\OneSignal\OneSignalOptions;

final class OneSignalOptionsTest extends TestCase
{
    public function testOneSignalOptions()
    {
        $oneSignalOptions = (new OneSignalOptions())
            ->headings(['en' => 'English Heading', 'fr' => 'French Heading'])
            ->contents(['en' => 'English Content', 'fr' => 'French Content'])
            ->url('https://example.com')
            ->data(['foo' => 'bar'])
            ->sendAfter(new \DateTimeImmutable('Thu Sep 24 2015 14:00:00 GMT-0700 (PDT)'))
            ->externalId('d637f30d-f709-4bed-9e2c-63637cb91894');

        $this->assertSame([
            'headings' => ['en' => 'English Heading', 'fr' => 'French Heading'],
            'contents' => ['en' => 'English Content', 'fr' => 'French Content'],
            'url' => 'https://example.com',
            


    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.