Skip to content

Commit a29bbec

Browse files
p-bystritskyDen4ik
authored andcommitted
#21200: Static test fix.
1 parent 643ea4f commit a29bbec

File tree

7 files changed

+36
-16
lines changed

7 files changed

+36
-16
lines changed

app/code/Magento/Review/Block/Customer/View.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Review\Block\Customer;
78

89
use Magento\Catalog\Model\Product;
@@ -202,7 +203,7 @@ public function dateFormat($date)
202203
}
203204

204205
/**
205-
* @return string
206+
* @inheritDoc
206207
*/
207208
protected function _toHtml()
208209
{

app/code/Magento/Review/Block/Product/ReviewRenderer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class ReviewRenderer extends \Magento\Framework\View\Element\Template implements
4444
/**
4545
* @param \Magento\Framework\View\Element\Template\Context $context
4646
* @param \Magento\Review\Model\ReviewFactory $reviewFactory
47-
* @param ReviewSummaryFactory $reviewSummaryFactory
4847
* @param array $data
48+
* @param ReviewSummaryFactory $reviewSummaryFactory
4949
*/
5050
public function __construct(
5151
\Magento\Framework\View\Element\Template\Context $context,
@@ -54,7 +54,8 @@ public function __construct(
5454
ReviewSummaryFactory $reviewSummaryFactory = null
5555
) {
5656
$this->_reviewFactory = $reviewFactory;
57-
$this->reviewSummaryFactory = $reviewSummaryFactory ?? ObjectManager::getInstance()->get(ReviewSummaryFactory::class);
57+
$this->reviewSummaryFactory = $reviewSummaryFactory ??
58+
ObjectManager::getInstance()->get(ReviewSummaryFactory::class);
5859
parent::__construct($context, $data);
5960
}
6061

@@ -94,7 +95,7 @@ public function getReviewsSummaryHtml(
9495
);
9596
}
9697

97-
if (!$product->getRatingSummary() && !$displayIfNoReviews) {
98+
if (null === $product->getRatingSummary() && !$displayIfNoReviews) {
9899
return '';
99100
}
100101
// pick template among available

app/code/Magento/Review/Model/ResourceModel/Review/Summary.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ public function reAggregate($summary)
7979
* Append review summary fields to product collection
8080
*
8181
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection
82-
* @param $storeId
83-
* @param $entityCode
82+
* @param string $storeId
83+
* @param string $entityCode
8484
* @return Summary
8585
* @throws \Magento\Framework\Exception\LocalizedException
8686
*/
8787
public function appendSummaryFieldsToCollection(
8888
\Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection,
89-
$storeId,
90-
$entityCode
89+
string $storeId,
90+
string $entityCode
9191
) {
9292
if (!$productCollection->isLoaded()) {
9393
$summaryEntitySubSelect = $this->getConnection()->select();
@@ -99,7 +99,10 @@ public function appendSummaryFieldsToCollection(
9999
'entity_code = ?',
100100
$entityCode
101101
);
102-
$joinCond = new \Zend_Db_Expr("e.entity_id = review_summary.entity_pk_value AND review_summary.store_id = {$storeId} AND review_summary.entity_type = ({$summaryEntitySubSelect})");
102+
$joinCond = new \Zend_Db_Expr(
103+
"e.entity_id = review_summary.entity_pk_value AND review_summary.store_id = {$storeId}"
104+
. " AND review_summary.entity_type = ({$summaryEntitySubSelect})"
105+
);
103106
$productCollection->getSelect()
104107
->joinLeft(
105108
['review_summary' => $this->getMainTable()],

app/code/Magento/Review/Model/Review.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public function appendSummary($collection)
318318
$entityIds[] = $item->getEntityId();
319319
}
320320

321-
if (sizeof($entityIds) == 0) {
321+
if (count($entityIds) === 0) {
322322
return $this;
323323
}
324324

app/code/Magento/Review/Model/ReviewSummary.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010
use Magento\Framework\Model\AbstractModel;
1111
use Magento\Review\Model\ResourceModel\Review\Summary\CollectionFactory as SummaryCollectionFactory;
1212

13+
/**
14+
* ReviewSummary model.
15+
*/
1316
class ReviewSummary
1417
{
1518
/**
1619
* @var SummaryCollectionFactory
1720
*/
1821
private $summaryCollectionFactory;
1922

23+
/**
24+
* @param SummaryCollectionFactory $sumColFactory
25+
*/
2026
public function __construct(
2127
SummaryCollectionFactory $sumColFactory
2228
) {
@@ -27,18 +33,20 @@ public function __construct(
2733
* Append review summary data to product
2834
*
2935
* @param AbstractModel $object
30-
* @param $storeId
36+
* @param int $storeId
3137
* @param int $entityType
3238
*/
33-
public function appendSummaryDataToObject(AbstractModel $object, $storeId, $entityType = 1): void
39+
public function appendSummaryDataToObject(AbstractModel $object, int $storeId, int $entityType = 1): void
3440
{
3541
$summary = $this->summaryCollectionFactory->create()
3642
->addEntityFilter($object->getId(), $entityType)
3743
->addStoreFilter($storeId)
3844
->getFirstItem();
39-
$object->addData([
40-
'reviews_count' => $summary->getData('reviews_count'),
41-
'rating_summary' => $summary->getData('rating_summary')
42-
]);
45+
$object->addData(
46+
[
47+
'reviews_count' => $summary->getData('reviews_count'),
48+
'rating_summary' => $summary->getData('rating_summary')
49+
]
50+
);
4351
}
4452
}

app/code/Magento/Review/Observer/CatalogProductListCollectionAppendSummaryFieldsObserver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use Magento\Review\Model\ResourceModel\Review\SummaryFactory;
1313
use Magento\Store\Model\StoreManagerInterface;
1414

15+
/**
16+
* Append review summary to product list collection.
17+
*/
1518
class CatalogProductListCollectionAppendSummaryFieldsObserver implements ObserverInterface
1619
{
1720
/**
@@ -53,6 +56,7 @@ public function execute(EventObserver $observer)
5356
$this->storeManager->getStore()->getId(),
5457
\Magento\Review\Model\Review::ENTITY_PRODUCT_CODE
5558
);
59+
5660
return $this;
5761
}
5862
}

app/code/Magento/Review/Test/Unit/Model/ReviewSummaryTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1111
use PHPUnit\Framework\MockObject\MockObject;
1212

13+
/**
14+
* Test for Magento\Review\Model\ReviewSummary class.
15+
*/
1316
class ReviewSummaryTest extends \PHPUnit\Framework\TestCase
1417
{
1518
/**

0 commit comments

Comments
 (0)