This repository was archived by the owner on Apr 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed
app/code/Magento/Review/Block/Product
dev/tests/integration/testsuite/Magento/Review Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ public function getReviewsSummaryHtml(
57
57
$ templateType = self ::DEFAULT_VIEW ,
58
58
$ displayIfNoReviews = false
59
59
) {
60
+ if (!$ product ->getRatingSummary ()) {
61
+ $ this ->_reviewFactory ->create ()->getEntitySummary ($ product , $ this ->_storeManager ->getStore ()->getId ());
62
+ }
63
+
60
64
if (!$ product ->getRatingSummary () && !$ displayIfNoReviews ) {
61
65
return '' ;
62
66
}
@@ -68,9 +72,6 @@ public function getReviewsSummaryHtml(
68
72
69
73
$ this ->setDisplayIfEmpty ($ displayIfNoReviews );
70
74
71
- if (!$ product ->getRatingSummary ()) {
72
- $ this ->_reviewFactory ->create ()->getEntitySummary ($ product , $ this ->_storeManager ->getStore ()->getId ());
73
- }
74
75
$ this ->setProduct ($ product );
75
76
76
77
return $ this ->toHtml ();
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ namespace Magento \Review \Block \Product ;
8
+
9
+ class ReviewRendererTest extends \PHPUnit \Framework \TestCase
10
+ {
11
+ /**
12
+ * @magentoDataFixture Magento/Review/_files/different_reviews.php
13
+ * @magentoAppArea frontend
14
+ */
15
+ public function testGetReviewSummaryHtml ()
16
+ {
17
+ $ productSku = 'simple ' ;
18
+ $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
19
+ /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
20
+ $ productRepository = $ objectManager ->create (\Magento \Catalog \Api \ProductRepositoryInterface::class);
21
+ $ product = $ productRepository ->get ($ productSku );
22
+ /** @var \Magento\Review\Block\Product\ReviewRenderer $reviewRenderer */
23
+ $ reviewRenderer = $ objectManager ->create (\Magento \Review \Block \Product \ReviewRenderer::class);
24
+ $ actualResult = $ reviewRenderer ->getReviewsSummaryHtml ($ product );
25
+ $ this ->assertEquals (2 , $ reviewRenderer ->getReviewsCount ());
26
+ $ this ->assertNotEmpty ($ actualResult );
27
+ }
28
+ }
Original file line number Diff line number Diff line change 71
71
)->getStore ()->getId ()
72
72
]
73
73
)->save ();
74
+ $ review ->aggregate ();
You can’t perform that action at this time.
0 commit comments