diff --git a/features/product/viewing_product_reviews/viewing_product_reviews_on_product_details_page.feature b/features/product/viewing_product_reviews/viewing_product_reviews_on_product_details_page.feature
index cd7b97d759c..8e09379a169 100644
--- a/features/product/viewing_product_reviews/viewing_product_reviews_on_product_details_page.feature
+++ b/features/product/viewing_product_reviews/viewing_product_reviews_on_product_details_page.feature
@@ -13,7 +13,7 @@ Feature: Viewing product reviews on product's details page
And this product has also a review titled "Classic" and rated 5 added by customer "sir.terry@pratchett.com"
And I am a logged in customer
- @ui
+ @ui @api
Scenario: Viewing last 3 product reviews on product's details page
When I check this product's details
Then I should see 3 product reviews
diff --git a/src/Sylius/Behat/Context/Api/Shop/ProductReviewContext.php b/src/Sylius/Behat/Context/Api/Shop/ProductReviewContext.php
index 830f27e5881..3b4a843ee77 100644
--- a/src/Sylius/Behat/Context/Api/Shop/ProductReviewContext.php
+++ b/src/Sylius/Behat/Context/Api/Shop/ProductReviewContext.php
@@ -89,6 +89,39 @@ public function iLeaveACommentTitled(string $comment, string $title, ?string $em
$this->client->addRequestData('email', $email);
}
+ /**
+ * @Then I should see :amount product reviews
+ */
+ public function iShouldSeeProductReviews(int $amount = 0): void
+ {
+ /** @var ProductInterface $product */
+ $product = $this->sharedStorage->get('product');
+
+ $this->client->index();
+ $this->client->addFilter('reviewSubject', $this->iriConverter->getIriFromItem($product));
+ $this->client->addFilter('itemsPerPage', 3);
+ $this->client->addFilter('order[createdAt]', 'desc');
+ $this->client->filter();
+
+ Assert::same($this->responseChecker->countCollectionItems($this->client->getLastResponse()), $amount);
+ }
+
+ /**
+ * @Then I should see reviews titled :titleOne, :titleTwo and :titleThree
+ */
+ public function iShouldSeeReviewsTitledAnd(string ...$titles): void
+ {
+ Assert::true($this->hasReviewsWithTitles($titles));
+ }
+
+ /**
+ * @Then I should not see review titled :title
+ */
+ public function iShouldNotSeeReviewTitled(string $title): void
+ {
+ Assert::false($this->hasReviewsWithTitles([$title]));
+ }
+
/**
* @When I rate it with :rating point(s)
*/
@@ -126,4 +159,15 @@ public function iShouldNotSeeReviewTitledInTheList(string $title): void
{
Assert::isEmpty($this->responseChecker->getCollectionItemsWithValue($this->client->getLastResponse(), 'title', $title));
}
+
+ private function hasReviewsWithTitles(array $titles): bool
+ {
+ foreach ($titles as $title) {
+ if (!$this->responseChecker->hasItemWithValue($this->client->getLastResponse(), 'title', $title)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/ProductReview.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/ProductReview.xml
index 293d748c0c9..ab2f0c81c75 100644
--- a/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/ProductReview.xml
+++ b/src/Sylius/Bundle/ApiBundle/Resources/config/api_resources/ProductReview.xml
@@ -43,6 +43,7 @@
/shop/product-reviews
sylius.api.product_review_product_filter
+ sylius.api.product_review_date_filter
diff --git a/src/Sylius/Bundle/ApiBundle/Resources/config/services/filters.xml b/src/Sylius/Bundle/ApiBundle/Resources/config/services/filters.xml
index f3e18f38cd9..29666cedb15 100644
--- a/src/Sylius/Bundle/ApiBundle/Resources/config/services/filters.xml
+++ b/src/Sylius/Bundle/ApiBundle/Resources/config/services/filters.xml
@@ -61,6 +61,13 @@
+
+
+
+
+
+
+