createReviews example


        $this->ids = new TestDataCollection();

        $this->createData();

        $this->browser = $this->createCustomSalesChannelBrowser([
            'id' => $this->ids->create('sales-channel'),
        ]);

        $this->setVisibilities();

        $this->createReviews();
    }

    public function testLoad(): void
    {
        $this->browser->request('POST', $this->getUrl());

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

        static::assertArrayHasKey('total', $response);
        static::assertEquals(5, $response['total']);
    }

    
$criteriaCollection = $this->buyBoxResolver->collect($slot$resolverContext);

        static::assertNull($criteriaCollection);
    }

    public function testReviewCountLoaded(): void
    {
        $productId = Uuid::randomHex();
        $saleChannelContext = $this->createSalesChannelContext();

        $this->createProduct($productId);
        $this->createReviews($productId);

        $fieldConfig = new FieldConfigCollection();
        $fieldConfig->add(new FieldConfig('product', FieldConfig::SOURCE_STATIC, $productId));

        $slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('buy-box');
        $slot->setFieldConfig($fieldConfig);

        $product = new SalesChannelProductEntity();
        $product->setId($productId);

        
/** @var EntityRepository $productRepository */
        $productRepository = $this->getContainer()->get('product.repository');
        $this->productRepository = $productRepository;

        $this->createCustomer();
        $this->createProduct();
    }

    public function testCreatingNewReview(): void
    {
        $this->createReviews();

        $customer = $this->customerRepository->search(
            new Criteria([$this->ids->get('customer')]),
            Context::createDefaultContext()
        )->first();
        static::assertInstanceOf(CustomerEntity::class$customer);
        static::assertSame(1, $customer->getReviewCount());
    }

    public function testDeletingNewReview(): void
    {
        
$this->expectException(ProductNotFoundException::class);
        $this->getPageLoader()->load($request$context);
    }

    public function testItLoadsReviews(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);

        $context = $this->createSalesChannelContextWithNavigation();
        $product = $this->getRandomProduct($context);

        $this->createReviews($product$context);

        $request = new Request([][]['productId' => $product->getId()]);

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(ReviewLoaderResult::class$page->getReviews());
        static::assertCount(6, $page->getReviews());
        static::assertInstanceOf(RatingMatrix::class$page->getReviews()->getMatrix());

        $matrix = $page->getReviews()->getMatrix();

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