createProductOnDatabase example

public function testMergedHintIsAdded(): void
    {
        /** @var CustomerEntity|null $customer */
        $customer = $this->createCustomer();
        static::assertNotNull($customer);

        $contextToken = Uuid::randomHex();
        $productId = Uuid::randomHex();
        $context = Context::createDefaultContext();

        $this->createProductOnDatabase($productId, 'test.123', $context);
        $salesChannelContext = $this->getContainer()->get(SalesChannelContextFactory::class)->create(
            $contextToken,
            TestDefaults::SALES_CHANNEL
        );

        $this->getContainer()->get(SalesChannelContextPersister::class)->save(
            $contextToken,
            [
                'customerId' => $customer->getId(),
                'billingAddressId' => null,
                'shippingAddressId' => null,
            ],
$browser = $this->getBrowserWithLoggedInCustomer();
        $browser->followRedirects(true);

        // Clear flashback from login and/or register         /** @var Session $session */
        $session = $this->getSession();
        $session->getFlashBag()->clear();

        $browserSalesChannelId = $browser->getServerParameter('test-sales-channel-id');

        $productId = Uuid::randomHex();
        $this->createProductOnDatabase($productId, 'test.123', $browserSalesChannelId);

        foreach ($errors as $error) {
            $this->prepareErrors(
                $error,
                $browser,
                $browserSalesChannelId,
                $productId,
                $testSwitchToDefault
            );
        }

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