finishPage example

public function testCheckoutFinishPageLoadedHookScriptsAreExecuted(): void
    {
        $contextToken = Uuid::randomHex();

        $order = $this->performOrder('', false, null, $contextToken);

        $salesChannelContext = $this->createSalesChannelContext($contextToken);
        $request = $this->createRequest($salesChannelContext);
        $request->request->set('orderId', $order->getId());
        $requestDataBag = $this->createRequestDataBag('');

        $this->getContainer()->get(CheckoutController::class)->finishPage($request$salesChannelContext$requestDataBag);

        $traces = $this->getContainer()->get(ScriptTraces::class)->getTraces();
        static::assertArrayHasKey(CheckoutFinishPageLoadedHook::HOOK_NAME, $traces);
    }

    public function testCheckoutInfoWidget(): void
    {
        $contextToken = Uuid::randomHex();

        $cartService = $this->getContainer()->get(CartService::class);
        $cart = $cartService->createNew($contextToken);

        
$response = $this->controller->confirmPage($request$context);

        static::assertEquals(new Response()$response);
    }

    public function testFinishPageNoCustomer(): void
    {
        $context = $this->createMock(SalesChannelContext::class);
        $context->method('getCustomer')->willReturn(null);

        $response = $this->controller->finishPage(new Request()$contextnew RequestDataBag());

        static::assertEquals(new RedirectResponse('url')$response);
    }

    public function testFinishPageOrderNotFound(): void
    {
        $context = $this->createMock(SalesChannelContext::class);
        $context->method('getCustomer')->willReturn(new CustomerEntity());

        $this->finishPageLoaderMock->method('load')->willThrowException(OrderException::orderNotFound('not-found'));

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