Recipient example


    public function testImportanceLevelIsReflectedInFlashMessageType(
        FlashMessageImportanceMapperInterface $mapper,
        string $importance,
        string $expectedFlashMessageType
    ) {
        $session = $this->createMock(Session::class);
        $session->method('getFlashBag')->willReturn(new FlashBag());
        $browserChannel = $this->buildBrowserChannel($session$mapper);
        $notification = new Notification();
        $notification->importance($importance);
        $recipient = new Recipient('hello@example.com');

        $browserChannel->notify($notification$recipient);

        $this->assertEquals($expectedFlashMessageTypearray_key_first($session->getFlashBag()->all()));
    }

    public function testUnknownImportanceMappingIsReported()
    {
        $session = $this->createMock(Session::class);
        $session->method('getFlashBag')->willReturn(new FlashBag());
        $browserChannel = $this->buildBrowserChannel($sessionnew DefaultFlashMessageImportanceMapper());
        
/** * @author Jan Schädlich <jan.schaedlich@sensiolabs.de> */
class EmailMessageTest extends TestCase
{
    public function testEnsureNonEmptyEmailOnCreationFromNotification()
    {
        $this->expectException(\InvalidArgumentException::class);
        $this->expectExceptionMessage('"Symfony\Component\Notifier\Message\EmailMessage" needs an email, it cannot be empty.');

        EmailMessage::fromNotification(new Notification()new Recipient('', '+3312345678'));
    }
}
use Symfony\Component\Notifier\Recipient\Recipient;

/** * @author Jan Schädlich <jan.schaedlich@sensiolabs.de> */
class RecipientTest extends TestCase
{
    public function testCannotBeConstructedWithoutEmailAndWithoutPhone()
    {
        $this->expectException(InvalidArgumentException::class);

        new Recipient('', '');
    }

    /** * @dataProvider provideValidEmailAndPhone */
    public function testCanBeConstructed(string $email, string $phone)
    {
        $recipient = new Recipient($email$phone);

        $this->assertSame($email$recipient->getEmail());
        $this->assertSame($phone$recipient->getPhone());
    }
Home | Imprint | This part of the site doesn't use cookies.