Address example

'senderEmail' => 'me@shopware.com',
            'subject' => 'Test email',
            'contentPlain' => 'Content plain',
            'contentHtml' => 'Content html',
            'salesChannelId' => $salesChannelId,
        ];

        $email = (new Email())->subject($data['subject'])
            ->html($data['contentHtml'])
            ->text($data['contentPlain'])
            ->to('me@shopware.com')
            ->from(new Address($data['senderEmail']));

        $this->mailFactory->expects(static::once())->method('create')->willReturn($email);
        $this->templateRenderer->expects(static::exactly(4))->method('render')->willReturn('');
        $this->eventDispatcher->expects(static::exactly(3))->method('dispatch')->willReturnOnConsecutiveCalls(
            static::isInstanceOf(MailBeforeValidateEvent::class),
            static::isInstanceOf(MailBeforeSentEvent::class),
            static::isInstanceOf(MailSentEvent::class)
        );
        $email = $this->mailService->send($data, Context::createDefaultContext());

        static::assertInstanceOf(Email::class$email);
    }
static::assertEquals(['foo' => 'bar']$flow->data()['data']);
    }

    public function testInstantiate(): void
    {
        $context = Context::createDefaultContext();
        $customerId = Uuid::randomHex();
        $email = (new Email())->subject('test subject')
            ->html('content html')
            ->text('content plain')
            ->to('test@shopware.com')
            ->from(new Address('test@shopware.com'));

        $event = new MailBeforeSentEvent(
            [
                'customerId' => $customerId,
            ],
            $email,
            $context,
            CheckoutOrderPlacedEvent::EVENT_NAME
        );

        static::assertSame(Level::Info->value, $event->getLogLevel());
        
Home | Imprint | This part of the site doesn't use cookies.