FlowSendMailActionEvent example

class FlowSendMailActionEventTest extends TestCase
{
    public function testGetContextWithFlowEvent(): void
    {
        $event = $this->createMock(StorableFlow::class);
        $event->expects(static::once())
            ->method('getContext')
            ->willReturn(Context::createDefaultContext());

        $mailTemplate = new MailTemplateEntity();

        $mailEvent = new FlowSendMailActionEvent(new DataBag()$mailTemplate$event);
        $context = $mailEvent->getContext();

        static::assertEquals($context, Context::createDefaultContext());
    }

    public function testGetDataBag(): void
    {
        $mailTemplate = new MailTemplateEntity();
        $flowEvent = $this->createMock(StorableFlow::class);

        $expectDataBag = new DataBag(['data' => 'data']);
        
$data->set('attachmentsConfig', new MailAttachmentsConfig(
            $flow->getContext(),
            $mailTemplate,
            $extension,
            $eventConfig,
            $flow->getData(OrderAware::ORDER_ID),
        ));

        $this->setReplyTo($data$eventConfig$flow->getData(FlowMailVariables::CONTACT_FORM_DATA, []));

        $this->eventDispatcher->dispatch(new FlowSendMailActionEvent($data$mailTemplate$flow));

        if ($data->has('templateId')) {
            $this->updateMailTemplateType(
                $flow->getContext(),
                $flow,
                $flow->data(),
                $mailTemplate
            );
        }

        $templateData = [
            
Home | Imprint | This part of the site doesn't use cookies.