prefixed example



    /** * @depends testIndexing */
    public function testEmptySearch(IdsCollection $data): void
    {
        try {
            $searcher = $this->createEntitySearcher();

            // check simple search without any restrictions             $criteria = new Criteria($data->prefixed('product-'));
            $criteria->addState(Criteria::STATE_ELASTICSEARCH_AWARE);
            $products = $searcher->search($this->productDefinition, $criteria$this->context);
            static::assertCount(\count($data->prefixed('product-'))$products->getIds());
        } catch (\Exception $e) {
            static::tearDown();

            throw $e;
        }
    }

    /** * @depends testIndexing */
$this->salesChannelContext->getContext()->scope(Context::SYSTEM_SCOPE, function DContext $context) use ($products): void {
            $this->productRepository->create($products$context);
            $downloads = array_merge(...array_column($products, 'downloads'));

            foreach ($downloads as $download) {
                $media = $download['media'];
                $mediaFile = $this->fileFetcher->fetchBlob($media['id']$media['fileExtension'], '');
                $this->fileSaver->persistFileToMedia($mediaFile$media['fileName']$media['id']$context);
            }
        });

        foreach ($ids->prefixed('product-') as $id) {
            $cart = $this->addProduct($id, 1, $cart$this->cartService, $this->salesChannelContext);
        }

        return $cart;
    }

    private function changeTransactionStateToPaid(string $orderId): void
    {
        $transaction = $this->orderTransactionRepository
            ->search(
                (new Criteria())
                    
->create($media, Context::createDefaultContext());

        $avatar = [
            'id' => $userId,
            'avatarId' => $ids->get('with-avatar'),
        ];

        $this->getContainer()->get('user.repository')
            ->update([$avatar], Context::createDefaultContext());

        $result = $this->getContainer()->get('product.repository')
            ->searchIds(new Criteria($ids->prefixed('product-')), Context::createDefaultContext());

        static::assertEquals(\count($products)$result->getTotal());

        return $ids;
    }

    /** * @depends testIndexing */
    public function testOneToOne(IdsCollection $ids): void
    {
        

        $this->productRepository = $this->getContainer()->get('product.repository');
        $this->statesUpdater = $this->getContainer()->get(StatesUpdater::class);
        $this->connection = $this->getContainer()->get(Connection::class);
    }

    public function testUpdateProductStates(): void
    {
        $ids = new IdsCollection();
        $this->prepareProducts($ids);

        $productIds = $ids->prefixed('product-');
        $this->statesUpdater->update($productIds, Context::createDefaultContext());

        $products = $this->productRepository
            ->search(new Criteria($productIds), Context::createDefaultContext())
            ->getEntities();

        $product1 = $products->get($ids->get('product-1'));
        $product2 = $products->get($ids->get('product-2'));
        $product3 = $products->get($ids->get('product-3'));

        static::assertInstanceOf(ProductEntity::class$product1);
        
'media' => ['fileName' => 'foo' . $i . '_3', 'fileExtension' => 'pdf', 'private' => true]],
                ],
            ]);
        }

        $this->context->getContext()->scope(Context::SYSTEM_SCOPE, function DContext $context) use ($productPayload): void {
            $this->getContainer()->get('product.repository')->create($productPayload$context);
        });

        $this->cart = new Cart($this->context->getToken());

        foreach ($this->ids->prefixed('product-state-') as $id) {
            $this->cart->getLineItems()->add(new LineItem(Uuid::randomHex(), LineItem::PRODUCT_LINE_ITEM_TYPE, $id));
        }

        $this->getContainer()->get(ProductCartProcessor::class)->collect($this->cart->getData()$this->cart, $this->context, new CartBehavior());
    }

    #[Bench\BeforeMethods(['setupWithLogin'])]     #[Bench\Assert('mode(variant.time.avg) < 150ms +/- 20ms')]     public function bench_order_10_physical_products(): void
    {
        $this->cart->setLineItems($this->cart->getLineItems()->filter(fn (LineItem $lineItem): bool => \in_array($lineItem->getReferencedId()$this->ids->prefixed('product-state-physical-'), true)));
        
/** * @dataProvider breadcrumbDataProvider * * @group slow */
    public function testIsWithoutEntrypoint(string $key, bool $withSalesChannel, bool $withCategoryId = false): void
    {
        $categoryId = $withCategoryId ? $this->ids->get($key) : null;
        $salesChannel = $withSalesChannel ? $this->salesChannelContext->getSalesChannel() : null;

        /** @var CategoryCollection $categories */
        $categories = $this->categoryRepository->search(new Criteria($this->ids->prefixed($key))new Context(
            new SystemSource(),
            [],
            Defaults::CURRENCY,
            [Defaults::LANGUAGE_SYSTEM]
        ))->getEntities();

        $category1 = $categories->get($this->ids->get($key));
        $category2 = $categories->get($this->ids->get($key . '-a-1'));
        $category3 = $categories->get($this->ids->get($key . '-a-2'));
        static::assertInstanceOf(CategoryEntity::class$category1);
        static::assertInstanceOf(CategoryEntity::class$category2);
        


        $context = $this->context->getContext();
        $context->addState(EntityIndexerRegistry::DISABLE_INDEXING);

        $this->getContainer()->get('rule.repository')->create($rulePayload$context);
    }

    #[Bench\Assert('mode(variant.time.avg) < 50ms +/- 10ms')]     public function bench_updating_areas_with_100_rules(): void
    {
        $this->getContainer()->get(RuleAreaUpdater::class)->update(array_values($this->ids->prefixed('rule-')));
    }
}
Home | Imprint | This part of the site doesn't use cookies.