Skip to content

Commit fd1e1f9

Browse files
author
Denys Rudchenko
committed
MAGETWO-35744: [MX] [Nord] Code coverage - Sprint 20
- MAGETWO-36954: Decrease CRAP of Magento\Review\Model\Resource\Rating\Collection::addEntitySummaryToItem
1 parent c78ae29 commit fd1e1f9

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

dev/tests/integration/testsuite/Magento/Review/Model/Resource/Rating/CollectionTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,19 @@ public function testAddEntitySummaryToItem()
2727
$ratingData = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
2828
->get('Magento\Framework\Registry')
2929
->registry('rating_data');
30-
$this->collection->addEntitySummaryToItem($ratingData->getEntityId(), $ratingData->getStoreId());
30+
31+
$result = $this->collection->addEntitySummaryToItem($ratingData->getEntityId(), $ratingData->getStoreId());
32+
$this->assertEquals($this->collection, $result);
33+
}
34+
35+
public function testAddEntitySummaryToItemEmpty()
36+
{
37+
foreach ($this->collection->getItems() as $item) {
38+
$item->delete();
39+
}
40+
$this->collection->clear();
41+
$result = $this->collection->addEntitySummaryToItem(1, 1);
42+
$this->assertEquals($this->collection, $result);
3143
}
3244

3345
public function testAddStoreData()

dev/tests/integration/testsuite/Magento/Review/_files/customer_rating.php

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,38 @@
55
*/
66
require __DIR__ . '/customer_review.php';
77

8+
$storeId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
9+
->get('Magento\Store\Model\StoreManagerInterface')
10+
->getStore()
11+
->getId();
12+
/** @var \Magento\Review\Model\Rating $ratingModel */
813
$ratingModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
914
'Magento\Review\Model\Rating',
1015
['data' => [
1116
'rating_code' => 'test',
12-
'rating_codes' => ['test'],
1317
'position' => 0,
14-
'isActive' => 1,
15-
'entityId' => $review->getEntityId()
18+
'isActive' => 1
1619
]]
1720
);
21+
$ratingModel->setStoreId($storeId)
22+
->setStores([$storeId])
23+
->setEntityId($ratingModel->getEntityIdByCode(Magento\Review\Model\Rating::ENTITY_PRODUCT_CODE))
24+
->setRatingCodes(['test']);
1825
$ratingModel->save();
26+
27+
/** @var \Magento\Review\Model\Rating\Option $optionModel */
28+
$optionModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
29+
'Magento\Review\Model\Rating\Option'
30+
);
31+
$optionModel->setCode(1)
32+
->setValue(1)
33+
->setRatingId($ratingModel->getId())
34+
->setPosition(1)
35+
->setReviewId($review->getId())
36+
->setEntityPkValue($product->getId())
37+
->save();
38+
$optionModel->addVote();
39+
1940
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry')->register(
2041
'rating_data',
2142
$ratingModel

0 commit comments

Comments
 (0)