getMailStruct example

public static function assertMailEvent(
        string $expectedClass,
        ShopwareEvent $event,
        SalesChannelContext $salesChannelContext
    ): void {
        TestCase::assertInstanceOf($expectedClass$event);
        TestCase::assertSame($salesChannelContext->getContext()$event->getContext());
    }

    public static function assertMailRecipientStructEvent(MailRecipientStruct $expectedStruct, MailAware $event): void
    {
        TestCase::assertSame($expectedStruct->getRecipients()$event->getMailStruct()->getRecipients());
    }

    protected function catchEvent(string $eventName, ?object &$eventResult): void
    {
        $eventDispatcher = $this->getContainer()->get('event_dispatcher');
        $this->addEventListener($eventDispatcher$eventNamestatic function D$event) use (&$eventResult): void {
            $eventResult = $event;
        });
    }
}

    public function store(FlowEventAware $event, array $stored): array
    {
        if (!$event instanceof MailAware) {
            return $stored;
        }

        if (!isset($stored[MailAware::MAIL_STRUCT])) {
            try {
                $mailStruct = $event->getMailStruct();
                $data = [
                    'recipients' => $mailStruct->getRecipients(),
                    'bcc' => $mailStruct->getBcc(),
                    'cc' => $mailStruct->getCc(),
                ];

                $stored[MailAware::MAIL_STRUCT] = $data;
            } catch (MailEventConfigurationException) {
            }
        }

        
$context = Context::createDefaultContext();
        $salesChannelId = 'foo';
        $mailRecipientStruct = new MailRecipientStruct(['foo' => 'bar']);
        $data = new DataBag(['baz']);
        $productId = 'bar';
        $customerId = 'bar';

        $event = new ReviewFormEvent($context$salesChannelId$mailRecipientStruct$data$productId$customerId);

        static::assertEquals($context$event->getContext());
        static::assertEquals($salesChannelId$event->getSalesChannelId());
        static::assertEquals($mailRecipientStruct$event->getMailStruct());
        static::assertEquals($data->all()$event->getReviewFormData());
        static::assertEquals($productId$event->getProductId());
        static::assertEquals($customerId$event->getCustomerId());
    }

    public function testScalarValuesCorrectly(): void
    {
        $event = new ReviewFormEvent(
            Context::createDefaultContext(),
            'sales-channel-id',
            new MailRecipientStruct(['foo', 'bar']),
            
Home | Imprint | This part of the site doesn't use cookies.