BandwidthOptions example



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

use PHPUnit\Framework\TestCase;
use Symfony\Component\Notifier\Bridge\Bandwidth\BandwidthOptions;

class BandwidthOptionsTest extends TestCase
{
    public function testBandwidthOptions()
    {
        $bandwidthOptions = (new BandwidthOptions())
            ->media(['foo'])
            ->tag('test_tag')
            ->accountId('test_account_id')
            ->applicationId('test_application_id')
            ->expiration('test_expiration')
            ->priority('test_priority');

        self::assertSame([
            'media' => ['foo'],
            'tag' => 'test_tag',
            'accountId' => 'test_account_id',
            


    public function invalidFromProvider(): iterable
    {
        yield 'no zero at start if phone number' => ['+0'];
        yield 'phone number too short' => ['+1'];
    }

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

    /** * @dataProvider invalidFromProvider */
    public function testInvalidArgumentExceptionIsThrownIfFromIsInvalid(string $from)
    {
        $transport = $this->createTransport(null, $from);

        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage(sprintf('The "From" number "%s" is not a valid phone number. The number must be in E.164 format.', $from));

        
Home | Imprint | This part of the site doesn't use cookies.