@@ -468,13 +468,15 @@ public function testAddChildProductAlreadyExistsInOption()
468
468
*/
469
469
public function testAddChildCouldNotSave ()
470
470
{
471
+ $ websiteId = 100 ;
471
472
$ productLink = $ this ->getMockBuilder (\Magento \Bundle \Api \Data \LinkInterface::class)
472
- ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' ])
473
+ ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' , ' getWebsiteId ' ])
473
474
->disableOriginalConstructor ()
474
475
->getMockForAbstractClass ();
475
476
$ productLink ->expects ($ this ->any ())->method ('getSku ' )->will ($ this ->returnValue ('linked_product_sku ' ));
476
477
$ productLink ->expects ($ this ->any ())->method ('getOptionId ' )->will ($ this ->returnValue (1 ));
477
478
$ productLink ->expects ($ this ->any ())->method ('getSelectionId ' )->will ($ this ->returnValue (1 ));
479
+ $ productLink ->expects ($ this ->any ())->method ('getWebsiteId ' )->will ($ this ->returnValue ($ websiteId ));
478
480
479
481
$ this ->metadataMock ->expects ($ this ->once ())->method ('getLinkField ' )->willReturn ($ this ->linkField );
480
482
$ productMock = $ this ->createMock (\Magento \Catalog \Model \Product::class);
@@ -541,13 +543,15 @@ function () {
541
543
542
544
public function testAddChild ()
543
545
{
546
+ $ websiteId = 100 ;
544
547
$ productLink = $ this ->getMockBuilder (\Magento \Bundle \Api \Data \LinkInterface::class)
545
- ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' ])
548
+ ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' , ' getWebsiteId ' ])
546
549
->disableOriginalConstructor ()
547
550
->getMockForAbstractClass ();
548
551
$ productLink ->expects ($ this ->any ())->method ('getSku ' )->will ($ this ->returnValue ('linked_product_sku ' ));
549
552
$ productLink ->expects ($ this ->any ())->method ('getOptionId ' )->will ($ this ->returnValue (1 ));
550
553
$ productLink ->expects ($ this ->any ())->method ('getSelectionId ' )->will ($ this ->returnValue (1 ));
554
+ $ productLink ->expects ($ this ->any ())->method ('getWebsiteId ' )->will ($ this ->returnValue ($ websiteId ));
551
555
552
556
$ this ->metadataMock ->expects ($ this ->once ())->method ('getLinkField ' )->willReturn ($ this ->linkField );
553
557
$ productMock = $ this ->createMock (\Magento \Catalog \Model \Product::class);
@@ -620,9 +624,10 @@ public function testSaveChild()
620
624
$ linkProductId = 45 ;
621
625
$ parentProductId = 32 ;
622
626
$ bundleProductSku = 'bundleProductSku ' ;
627
+ $ websiteId = 100 ;
623
628
624
629
$ productLink = $ this ->getMockBuilder (\Magento \Bundle \Api \Data \LinkInterface::class)
625
- ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' ])
630
+ ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' , ' getWebsiteId ' ])
626
631
->disableOriginalConstructor ()
627
632
->getMockForAbstractClass ();
628
633
$ productLink ->expects ($ this ->any ())->method ('getSku ' )->will ($ this ->returnValue ('linked_product_sku ' ));
@@ -636,6 +641,7 @@ public function testSaveChild()
636
641
->will ($ this ->returnValue ($ canChangeQuantity ));
637
642
$ productLink ->expects ($ this ->any ())->method ('getIsDefault ' )->will ($ this ->returnValue ($ isDefault ));
638
643
$ productLink ->expects ($ this ->any ())->method ('getSelectionId ' )->will ($ this ->returnValue ($ optionId ));
644
+ $ productLink ->expects ($ this ->any ())->method ('getWebsiteId ' )->will ($ this ->returnValue ($ websiteId ));
639
645
640
646
$ this ->metadataMock ->expects ($ this ->once ())->method ('getLinkField ' )->willReturn ($ this ->linkField );
641
647
$ productMock = $ this ->createMock (\Magento \Catalog \Model \Product::class);
@@ -677,7 +683,8 @@ public function testSaveChild()
677
683
'setSelectionPriceType ' ,
678
684
'setSelectionPriceValue ' ,
679
685
'setSelectionCanChangeQty ' ,
680
- 'setIsDefault '
686
+ 'setIsDefault ' ,
687
+ 'setWebsiteId '
681
688
]);
682
689
$ selection ->expects ($ this ->once ())->method ('save ' );
683
690
$ selection ->expects ($ this ->once ())->method ('load ' )->with ($ id )->will ($ this ->returnSelf ());
@@ -691,6 +698,7 @@ public function testSaveChild()
691
698
$ selection ->expects ($ this ->once ())->method ('setSelectionPriceValue ' )->with ($ price );
692
699
$ selection ->expects ($ this ->once ())->method ('setSelectionCanChangeQty ' )->with ($ canChangeQuantity );
693
700
$ selection ->expects ($ this ->once ())->method ('setIsDefault ' )->with ($ isDefault );
701
+ $ selection ->expects ($ this ->once ())->method ('setWebsiteId ' )->with ($ websiteId );
694
702
695
703
$ this ->bundleSelectionMock ->expects ($ this ->once ())->method ('create ' )->will ($ this ->returnValue ($ selection ));
696
704
$ this ->assertTrue ($ this ->model ->saveChild ($ bundleProductSku , $ productLink ));
@@ -704,14 +712,16 @@ public function testSaveChildFailedToSave()
704
712
$ id = 12 ;
705
713
$ linkProductId = 45 ;
706
714
$ parentProductId = 32 ;
715
+ $ websiteId = 200 ;
707
716
708
717
$ productLink = $ this ->getMockBuilder (\Magento \Bundle \Api \Data \LinkInterface::class)
709
- ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' ])
718
+ ->setMethods (['getSku ' , 'getOptionId ' , 'getSelectionId ' , ' getWebsiteId ' ])
710
719
->disableOriginalConstructor ()
711
720
->getMockForAbstractClass ();
712
721
$ productLink ->expects ($ this ->any ())->method ('getSku ' )->will ($ this ->returnValue ('linked_product_sku ' ));
713
722
$ productLink ->expects ($ this ->any ())->method ('getId ' )->will ($ this ->returnValue ($ id ));
714
723
$ productLink ->expects ($ this ->any ())->method ('getSelectionId ' )->will ($ this ->returnValue (1 ));
724
+ $ productLink ->expects ($ this ->any ())->method ('getWebsiteId ' )->will ($ this ->returnValue ($ websiteId ));
715
725
$ bundleProductSku = 'bundleProductSku ' ;
716
726
717
727
$ productMock = $ this ->createMock (\Magento \Catalog \Model \Product::class);
@@ -751,13 +761,15 @@ public function testSaveChildFailedToSave()
751
761
'setSelectionPriceType ' ,
752
762
'setSelectionPriceValue ' ,
753
763
'setSelectionCanChangeQty ' ,
754
- 'setIsDefault '
764
+ 'setIsDefault ' ,
765
+ 'setWebsiteId '
755
766
]);
756
767
$ mockException = $ this ->createMock (\Exception::class);
757
768
$ selection ->expects ($ this ->once ())->method ('save ' )->will ($ this ->throwException ($ mockException ));
758
769
$ selection ->expects ($ this ->once ())->method ('load ' )->with ($ id )->will ($ this ->returnSelf ());
759
770
$ selection ->expects ($ this ->any ())->method ('getId ' )->will ($ this ->returnValue ($ id ));
760
771
$ selection ->expects ($ this ->once ())->method ('setProductId ' )->with ($ linkProductId );
772
+ $ selection ->expects ($ this ->once ())->method ('setWebsiteId ' )->with ($ websiteId );
761
773
762
774
$ this ->bundleSelectionMock ->expects ($ this ->once ())->method ('create ' )->will ($ this ->returnValue ($ selection ));
763
775
$ this ->model ->saveChild ($ bundleProductSku , $ productLink );
0 commit comments