createDefaultSalesChannelContext example

private string $customerId;

    protected function setUp(): void
    {
        $this->cartService = $this->getContainer()->get(CartService::class);
        $this->productRepository = $this->getContainer()->get('product.repository');
        $this->orderRepository = $this->getContainer()->get('order.repository');
        $this->orderTransactionRepository = $this->getContainer()->get('order_transaction.repository');
        $this->flowRepository = $this->getContainer()->get('flow.repository');
        $this->customerId = $this->createCustomer();
        $this->salesChannelContext = $this->createDefaultSalesChannelContext();
        $this->orderTransactionStateHandler = $this->getContainer()->get(OrderTransactionStateHandler::class);
        $this->eventDispatcher = $this->getContainer()->get('event_dispatcher');
        $this->downloadRoute = $this->getContainer()->get(DownloadRoute::class);
        $this->fileSaver = $this->getContainer()->get(FileSaver::class);
        $this->fileFetcher = $this->getContainer()->get(FileFetcher::class);
    }

    /** * @param array<int, string[]> $productDownloads * * @dataProvider orderCaseProvider */
protected function setUp(): void
    {
        $this->cartService = $this->getContainer()->get(CartService::class);
        $this->productRepository = $this->getContainer()->get('product.repository');
        $this->orderRepository = $this->getContainer()->get('order.repository');
        $this->orderTransactionRepository = $this->getContainer()->get('order_transaction.repository');
        $this->orderTransactionStateHandler = $this->getContainer()->get(OrderTransactionStateHandler::class);
        $this->flowRepository = $this->getContainer()->get('flow.repository');
        $this->tagRepository = $this->getContainer()->get('tag.repository');
        $this->customerId = $this->createCustomer();
        $this->salesChannelContext = $this->createDefaultSalesChannelContext();
    }

    public function testFlowExecutesWithIfSequencesEvaluated(): void
    {
        $ids = new IdsCollection();

        $this->createTags($ids);

        $this->createFlow($ids);

        $this->placeOrder($ids);

        
$response = $browser->getResponse()->getContent();
        $response = json_decode($response ?: '', true, 512, \JSON_THROW_ON_ERROR);

        static::assertArrayHasKey('errors', $response);
        static::assertCount(2, $response['errors']);
        static::assertSame('/unitPrice', $response['errors'][0]['source']['pointer']);
        static::assertSame('/totalPrice', $response['errors'][1]['source']['pointer']);
    }

    public function testModifyShippingCosts(): void
    {
        $salesChannelContext = $this->createDefaultSalesChannelContext();
        $productId = Uuid::randomHex();
        $this->createTestFixtureProduct($productId, 119, 19, $this->getContainer()$salesChannelContext);

        $browser = $this->createCart(TestDefaults::SALES_CHANNEL, $salesChannelContext->getToken());
        $this->addProduct($browser, TestDefaults::SALES_CHANNEL, $productId);

        $browser->request(
            'PATCH',
            $this->getRootProxyUrl('/modify-shipping-costs'),
            [],
            [],
            [],
Home | Imprint | This part of the site doesn't use cookies.