getNewestOrder example

'stateId' => $this->getStateMachineState(OrderTransactionStates::STATE_MACHINE, OrderTransactionStates::STATE_OPEN),
            ],
        ]$context->getContext());

        /** @var AccountOverviewPageLoadedEvent $event */
        $event = null;
        $this->catchEvent(AccountOverviewPageLoadedEvent::class$event);

        $page = $this->getPageLoader()->load($request$context$this->createCustomer());

        static::assertInstanceOf(AccountOverviewPage::class$page);
        $order = $page->getNewestOrder();
        static::assertInstanceOf(OrderEntity::class$order);
        $transactions = $order->getTransactions();
        static::assertCount(2, $transactions);
        $transaction = $transactions->last();
        static::assertNotNull($transaction);
        static::assertSame(self::LAST_TRANSACTION_ID, $transaction->getId());
        self::assertPageEvent(AccountOverviewPageLoadedEvent::class$event$context$request$page);
    }

    public function testSalesChannelRestriction(): void
    {
        


        $this->orderRoute
            ->expects(static::once())
            ->method('load')
            ->willReturn($orderResponse);

        $customer = new CustomerEntity();
        $page = $this->pageLoader->load(new Request()$this->createMock(SalesChannelContext::class)$customer);

        static::assertInstanceOf(AccountOverviewPage::class$page);
        static::assertEquals($order$page->getNewestOrder());

        $events = $this->eventDispatcher->getEvents();
        static::assertCount(2, $events);

        static::assertInstanceOf(OrderRouteRequestEvent::class$events[0]);
        static::assertInstanceOf(AccountOverviewPageLoadedEvent::class$events[1]);
    }
}
Home | Imprint | This part of the site doesn't use cookies.