@@ -406,9 +406,13 @@ public function testAddChildLinkedProductIsComposite()
406
406
*/
407
407
public function testAddChildProductAlreadyExistsInOption ()
408
408
{
409
- $ productLink = $ this ->getMock (\Magento \Bundle \Api \Data \LinkInterface::class);
409
+ $ productLink = $ this ->getMockBuilder (\Magento \Bundle \Api \Data \LinkInterface::class)
410
+ ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' ])
411
+ ->disableOriginalConstructor ()
412
+ ->getMockForAbstractClass ();
410
413
$ productLink ->expects ($ this ->any ())->method ('getSku ' )->will ($ this ->returnValue ('linked_product_sku ' ));
411
414
$ productLink ->expects ($ this ->any ())->method ('getOptionId ' )->will ($ this ->returnValue (1 ));
415
+ $ productLink ->expects ($ this ->any ())->method ('getSelectionId ' )->will ($ this ->returnValue (1 ));
412
416
413
417
$ this ->metadataMock ->expects ($ this ->once ())->method ('getLinkField ' )->willReturn ($ this ->linkField );
414
418
$ productMock = $ this ->getMock (\Magento \Catalog \Model \Product::class, [], [], '' , false );
@@ -458,8 +462,8 @@ public function testAddChildProductAlreadyExistsInOption()
458
462
);
459
463
460
464
$ selections = [
461
- ['option_id ' => 1 , 'product_id ' => 12 ],
462
- ['option_id ' => 1 , 'product_id ' => 13 ],
465
+ ['option_id ' => 1 , 'product_id ' => 12 , ' parent_product_id ' => ' product_id ' ],
466
+ ['option_id ' => 1 , 'product_id ' => 13 , ' parent_product_id ' => ' product_id ' ],
463
467
];
464
468
$ bundle = $ this ->getMock (\Magento \Bundle \Model \ResourceModel \Bundle::class, [], [], '' , false );
465
469
$ bundle ->expects ($ this ->once ())->method ('getSelectionsData ' )
@@ -474,9 +478,13 @@ public function testAddChildProductAlreadyExistsInOption()
474
478
*/
475
479
public function testAddChildCouldNotSave ()
476
480
{
477
- $ productLink = $ this ->getMock (\Magento \Bundle \Api \Data \LinkInterface::class);
481
+ $ productLink = $ this ->getMockBuilder (\Magento \Bundle \Api \Data \LinkInterface::class)
482
+ ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' ])
483
+ ->disableOriginalConstructor ()
484
+ ->getMockForAbstractClass ();
478
485
$ productLink ->expects ($ this ->any ())->method ('getSku ' )->will ($ this ->returnValue ('linked_product_sku ' ));
479
486
$ productLink ->expects ($ this ->any ())->method ('getOptionId ' )->will ($ this ->returnValue (1 ));
487
+ $ productLink ->expects ($ this ->any ())->method ('getSelectionId ' )->will ($ this ->returnValue (1 ));
480
488
481
489
$ this ->metadataMock ->expects ($ this ->once ())->method ('getLinkField ' )->willReturn ($ this ->linkField );
482
490
$ productMock = $ this ->getMock (\Magento \Catalog \Model \Product::class, [], [], '' , false );
@@ -545,9 +553,13 @@ function () {
545
553
546
554
public function testAddChild ()
547
555
{
548
- $ productLink = $ this ->getMock (\Magento \Bundle \Api \Data \LinkInterface::class);
556
+ $ productLink = $ this ->getMockBuilder (\Magento \Bundle \Api \Data \LinkInterface::class)
557
+ ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' ])
558
+ ->disableOriginalConstructor ()
559
+ ->getMockForAbstractClass ();
549
560
$ productLink ->expects ($ this ->any ())->method ('getSku ' )->will ($ this ->returnValue ('linked_product_sku ' ));
550
561
$ productLink ->expects ($ this ->any ())->method ('getOptionId ' )->will ($ this ->returnValue (1 ));
562
+ $ productLink ->expects ($ this ->any ())->method ('getSelectionId ' )->will ($ this ->returnValue (1 ));
551
563
552
564
$ this ->metadataMock ->expects ($ this ->once ())->method ('getLinkField ' )->willReturn ($ this ->linkField );
553
565
$ productMock = $ this ->getMock (\Magento \Catalog \Model \Product::class, [], [], '' , false );
@@ -623,7 +635,10 @@ public function testSaveChild()
623
635
$ parentProductId = 32 ;
624
636
$ bundleProductSku = 'bundleProductSku ' ;
625
637
626
- $ productLink = $ this ->getMock (\Magento \Bundle \Api \Data \LinkInterface::class);
638
+ $ productLink = $ this ->getMockBuilder (\Magento \Bundle \Api \Data \LinkInterface::class)
639
+ ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' ])
640
+ ->disableOriginalConstructor ()
641
+ ->getMockForAbstractClass ();
627
642
$ productLink ->expects ($ this ->any ())->method ('getSku ' )->will ($ this ->returnValue ('linked_product_sku ' ));
628
643
$ productLink ->expects ($ this ->any ())->method ('getId ' )->will ($ this ->returnValue ($ id ));
629
644
$ productLink ->expects ($ this ->any ())->method ('getOptionId ' )->will ($ this ->returnValue ($ optionId ));
@@ -633,6 +648,7 @@ public function testSaveChild()
633
648
$ productLink ->expects ($ this ->any ())->method ('getPrice ' )->will ($ this ->returnValue ($ price ));
634
649
$ productLink ->expects ($ this ->any ())->method ('getCanChangeQuantity ' )->will ($ this ->returnValue ($ canChangeQuantity ));
635
650
$ productLink ->expects ($ this ->any ())->method ('getIsDefault ' )->will ($ this ->returnValue ($ isDefault ));
651
+ $ productLink ->expects ($ this ->any ())->method ('getSelectionId ' )->will ($ this ->returnValue ($ optionId ));
636
652
637
653
$ this ->metadataMock ->expects ($ this ->once ())->method ('getLinkField ' )->willReturn ($ this ->linkField );
638
654
$ productMock = $ this ->getMock (\Magento \Catalog \Model \Product::class, [], [], '' , false );
@@ -707,9 +723,13 @@ public function testSaveChildFailedToSave()
707
723
$ id = 12 ;
708
724
$ linkProductId = 45 ;
709
725
$ parentProductId = 32 ;
710
- $ productLink = $ this ->getMock (\Magento \Bundle \Api \Data \LinkInterface::class);
726
+ $ productLink = $ this ->getMockBuilder (\Magento \Bundle \Api \Data \LinkInterface::class)
727
+ ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' ])
728
+ ->disableOriginalConstructor ()
729
+ ->getMockForAbstractClass ();
711
730
$ productLink ->expects ($ this ->any ())->method ('getSku ' )->will ($ this ->returnValue ('linked_product_sku ' ));
712
731
$ productLink ->expects ($ this ->any ())->method ('getId ' )->will ($ this ->returnValue ($ id ));
732
+ $ productLink ->expects ($ this ->any ())->method ('getSelectionId ' )->will ($ this ->returnValue (1 ));
713
733
$ bundleProductSku = 'bundleProductSku ' ;
714
734
715
735
$ productMock = $ this ->getMock (\Magento \Catalog \Model \Product::class, [], [], '' , false );
0 commit comments