CodeExplorer getReviews example
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();
static::
assertEquals(3.333, \
round($matrix->
getAverageRating(), 3
));
static::
assertEquals(6,
$matrix->
getTotalReviewCount());
} public function testItLoadsReviewsWithCustomer(): void
{