placeRandomOrder example

'id' => $expectedCustomer->getId(),
                'email' => $expectedCustomer->getEmail(),
                'guest' => $expectedCustomer->getGuest(),
            ],
        ]$context);

        $salesChannel = $this->getContainer()->get(SalesChannelContextFactory::class)->create(
            $this->salesChannel->getToken(),
            $this->salesChannel->getSalesChannelId(),
            [SalesChannelContextService::CUSTOMER_ID => $expectedCustomer->getId()],
        );
        $orderId = $this->placeRandomOrder($salesChannel);
        $order = $this->orderRepository->search(new Criteria([$orderId])$context)->first();
        $this->orderRepository->update([
            [
                'id' => $order->getId(),
                'deepLinkCode' => $deepLinkCode = Random::getBase64UrlString(32),
                'orderCustomer.customerId' => $expectedCustomer->getId(),
            ],
        ]$context);

        $page = $this->getPageLoader()->load(
            new Request(
                [
static::assertInstanceOf(AccountOrderPage::class$page);
        static::assertSame(0, $page->getOrders()->count());
        self::assertPageEvent(AccountOrderPageLoadedEvent::class$event$context$request$page);
    }

    public function testSalesChannelRestriction(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $testContext = $this->createSalesChannelContext();

        $this->placeRandomOrder($context);
        $order = $this->placeRandomOrder($context);
        $this->getContainer()->get('order.repository')->update([
            [
                'id' => $order,
                'salesChannelId' => $testContext->getSalesChannel()->getId(),
            ],
        ]$context->getContext());

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

        
/** * @internal */
class OrderDetailPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testItLoadsOrders(): void
    {
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $orderId = $this->placeRandomOrder($context);

        $request = new Request();
        $request->query->set('id', $orderId);

        /** @var AccountOrderPageLoadedEvent|null $accountOrderDetailEvent */
        $accountOrderDetailEvent = null;
        $this->catchEvent(AccountOrderDetailPageLoadedEvent::class$accountOrderDetailEvent);

        /** @var OrderRouteRequestEvent|null $orderRequestEvent */
        $orderRequestEvent = null;
        $this->catchEvent(OrderRouteRequestEvent::class$orderRequestEvent);

        

class EditOrderPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;

    public function testEditOrderPageShouldLoad(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $orderId = $this->placeRandomOrder($context);

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

        $request->request->set('orderId', $orderId);
        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(AccountEditOrderPage::class$page);
        self::assertPageEvent(AccountEditOrderPageLoadedEvent::class$event$context$request$page);

        
$request = new Request([][]['orderId' => 'foo']);
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();

        $this->expectException(OrderException::class);

        $this->getPageLoader()->load($request$context);
    }

    public function testFinishPageLoading(): void
    {
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $orderId = $this->placeRandomOrder($context);
        $request = new Request([][]['orderId' => $orderId]);
        $eventWasThrown = false;
        $criteria = new Criteria([$orderId]);

        $this->addEventListener(
            $this->getContainer()->get('event_dispatcher'),
            CheckoutFinishPageOrderCriteriaEvent::class,
            static function DCheckoutFinishPageOrderCriteriaEvent $event) use ($criteria, &$eventWasThrown): void {
                static::assertSame($criteria->getIds()$event->getCriteria()->getIds());
                $eventWasThrown = true;
            }
        );

class OverviewPageTest extends TestCase
{
    use IntegrationTestBehaviour;
    use StorefrontPageTestBehaviour;
    private const LAST_TRANSACTION_ID = '00000000000000000000000000000000';

    public function testItLoadsTheOverview(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $orderId = $this->placeRandomOrder($context);
        $this->getContainer()->get('order_transaction.repository')->create([
            [
                // this id would result in being the first transaction with wrong sorting                 'id' => self::LAST_TRANSACTION_ID,
                'orderId' => $orderId,
                'amount' => new CalculatedPrice(10.0, 10.0, new CalculatedTaxCollection()new TaxRuleCollection()),
                'paymentMethodId' => $this->getValidPaymentMethodId(),
                'stateId' => $this->getStateMachineState(OrderTransactionStates::STATE_MACHINE, OrderTransactionStates::STATE_OPEN),
            ],
        ]$context->getContext());

        
Home | Imprint | This part of the site doesn't use cookies.