Skip to content

Commit ec8a756

Browse files
11209-wishlist-add-grouped-product-error
1 parent 9a4ccb7 commit ec8a756

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

app/code/Magento/GroupedProduct/Model/Wishlist/Product/Item.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function beforeRepresentProduct(
6868
* @param array $options1
6969
* @param array $options2
7070
* @return array
71+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
7172
*/
7273
public function beforeCompareOptions(
7374
WishlistItem $subject,
@@ -77,7 +78,7 @@ public function beforeCompareOptions(
7778
$diff = array_diff_key($options1, $options2);
7879

7980
if (!$diff) {
80-
foreach ($options1 as $key => $val) {
81+
foreach (array_keys($options1) as $key) {
8182
if (preg_match('/associated_product_\d+/', $key)) {
8283
unset($options1[$key]);
8384
unset($options2[$key]);

app/code/Magento/GroupedProduct/Test/Unit/Model/Wishlist/Product/ItemTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ protected function setUp()
6161
*/
6262
public function testBeforeRepresentProduct()
6363
{
64+
$testSimpleProdId = 34;
65+
$prodInitQty = 2;
66+
$prodQtyInWishlist = 3;
67+
$resWishlistQty = $prodInitQty + $prodQtyInWishlist;
6468
$superGroup = [
6569
'super_group' => [
6670
33 => "0",
@@ -71,12 +75,12 @@ public function testBeforeRepresentProduct()
7175

7276
$superGroupObj = new \Magento\Framework\DataObject($superGroup);
7377

74-
$this->productMock->expects($this->once())->method('getId')->willReturn(34);
78+
$this->productMock->expects($this->once())->method('getId')->willReturn($testSimpleProdId);
7579
$this->productMock->expects($this->once())->method('getTypeId')
7680
->willReturn(TypeGrouped::TYPE_CODE);
7781
$this->productMock->expects($this->once())->method('getCustomOptions')
7882
->willReturn(
79-
$this->getProductAssocOption(2, 34)
83+
$this->getProductAssocOption($prodInitQty, $testSimpleProdId)
8084
);
8185

8286
$wishlistItemProductMock = $this->createPartialMock(
@@ -85,13 +89,13 @@ public function testBeforeRepresentProduct()
8589
'getId',
8690
]
8791
);
88-
$wishlistItemProductMock->expects($this->once())->method('getId')->willReturn(34);
92+
$wishlistItemProductMock->expects($this->once())->method('getId')->willReturn($testSimpleProdId);
8993

9094
$this->subjectMock->expects($this->once())->method('getProduct')
9195
->willReturn($wishlistItemProductMock);
9296
$this->subjectMock->expects($this->once())->method('getOptionsByCode')
9397
->willReturn(
94-
$this->getWishlistAssocOption(3, 5, 34)
98+
$this->getWishlistAssocOption($prodQtyInWishlist, $resWishlistQty, $testSimpleProdId)
9599
);
96100
$this->subjectMock->expects($this->once())->method('getBuyRequest')->willReturn($superGroupObj);
97101

app/code/Magento/GroupedProduct/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"magento/module-quote": "*",
1919
"magento/module-sales": "*",
2020
"magento/module-store": "*",
21-
"magento/module-ui": "*"
21+
"magento/module-ui": "*",
22+
"magento/module-wishlist": "*"
2223
},
2324
"suggest": {
2425
"magento/module-grouped-product-sample-data": "*"

0 commit comments

Comments
 (0)