Skip to content

Commit

Permalink
11209-wishlist-add-grouped-product-error
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxRomanov4669 committed Jan 7, 2020
1 parent 9a4ccb7 commit ec8a756
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function beforeRepresentProduct(
* @param array $options1
* @param array $options2
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeCompareOptions(
WishlistItem $subject,
Expand All @@ -77,7 +78,7 @@ public function beforeCompareOptions(
$diff = array_diff_key($options1, $options2);

if (!$diff) {
foreach ($options1 as $key => $val) {
foreach (array_keys($options1) as $key) {
if (preg_match('/associated_product_\d+/', $key)) {
unset($options1[$key]);
unset($options2[$key]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ protected function setUp()
*/
public function testBeforeRepresentProduct()
{
$testSimpleProdId = 34;
$prodInitQty = 2;
$prodQtyInWishlist = 3;
$resWishlistQty = $prodInitQty + $prodQtyInWishlist;
$superGroup = [
'super_group' => [
33 => "0",
Expand All @@ -71,12 +75,12 @@ public function testBeforeRepresentProduct()

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

$this->productMock->expects($this->once())->method('getId')->willReturn(34);
$this->productMock->expects($this->once())->method('getId')->willReturn($testSimpleProdId);
$this->productMock->expects($this->once())->method('getTypeId')
->willReturn(TypeGrouped::TYPE_CODE);
$this->productMock->expects($this->once())->method('getCustomOptions')
->willReturn(
$this->getProductAssocOption(2, 34)
$this->getProductAssocOption($prodInitQty, $testSimpleProdId)
);

$wishlistItemProductMock = $this->createPartialMock(
Expand All @@ -85,13 +89,13 @@ public function testBeforeRepresentProduct()
'getId',
]
);
$wishlistItemProductMock->expects($this->once())->method('getId')->willReturn(34);
$wishlistItemProductMock->expects($this->once())->method('getId')->willReturn($testSimpleProdId);

$this->subjectMock->expects($this->once())->method('getProduct')
->willReturn($wishlistItemProductMock);
$this->subjectMock->expects($this->once())->method('getOptionsByCode')
->willReturn(
$this->getWishlistAssocOption(3, 5, 34)
$this->getWishlistAssocOption($prodQtyInWishlist, $resWishlistQty, $testSimpleProdId)
);
$this->subjectMock->expects($this->once())->method('getBuyRequest')->willReturn($superGroupObj);

Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/GroupedProduct/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"magento/module-quote": "*",
"magento/module-sales": "*",
"magento/module-store": "*",
"magento/module-ui": "*"
"magento/module-ui": "*",
"magento/module-wishlist": "*"
},
"suggest": {
"magento/module-grouped-product-sample-data": "*"
Expand Down

0 comments on commit ec8a756

Please sign in to comment.