@@ -231,7 +231,7 @@ protected function setUp()
231
231
'contentFactory ' => $ this ->contentFactoryMock ,
232
232
'mimeTypeExtensionMap ' => $ this ->mimeTypeExtensionMapMock ,
233
233
'linkTypeProvider ' => $ this ->linkTypeProviderMock ,
234
- 'imageProcessor ' => $ this ->imageProcessorMock
234
+ 'imageProcessor ' => $ this ->imageProcessorMock ,
235
235
]
236
236
);
237
237
}
@@ -271,6 +271,19 @@ public function testGetProductInEditMode()
271
271
$ this ->assertEquals ($ this ->productMock , $ this ->model ->get ('test_sku ' , true ));
272
272
}
273
273
274
+ public function testGetWithSetStoreId ()
275
+ {
276
+ $ productId = 123 ;
277
+ $ sku = 'test-sku ' ;
278
+ $ storeId = 7 ;
279
+ $ this ->productFactoryMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ this ->productMock );
280
+ $ this ->resourceModelMock ->expects ($ this ->once ())->method ('getIdBySku ' )->with ($ sku )->willReturn ($ productId );
281
+ $ this ->productMock ->expects ($ this ->once ())->method ('setData ' )->with ('store_id ' , $ storeId );
282
+ $ this ->productMock ->expects ($ this ->once ())->method ('load ' )->with ($ productId );
283
+ $ this ->productMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ($ productId );
284
+ $ this ->assertSame ($ this ->productMock , $ this ->model ->get ($ sku , false , $ storeId ));
285
+ }
286
+
274
287
/**
275
288
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
276
289
* @expectedExceptionMessage Requested product doesn't exist
@@ -729,8 +742,8 @@ public function saveExistingWithOptionsDataProvider()
729
742
[ //new option value
730
743
"title " => "DropdownOptions_3 " ,
731
744
"price " => 4 ,
732
- ]
733
- ]
745
+ ],
746
+ ],
734
747
],
735
748
[//new option
736
749
"type " => "checkbox " ,
@@ -739,7 +752,7 @@ public function saveExistingWithOptionsDataProvider()
739
752
"title " => "CheckBoxValue2 " ,
740
753
"price " => 5 ,
741
754
],
742
- ]
755
+ ],
743
756
],
744
757
];
745
758
@@ -819,16 +832,16 @@ public function saveExistingWithOptionsDataProvider()
819
832
"price " => 6 ,
820
833
"is_delete " => 1 ,
821
834
],
822
- ]
835
+ ],
823
836
],
824
837
[
825
838
"type " => "checkbox " ,
826
839
"values " => [
827
840
[
828
841
"title " => "CheckBoxValue2 " ,
829
842
"price " => 5 ,
830
- ]
831
- ]
843
+ ],
844
+ ],
832
845
],
833
846
[
834
847
"option_id " => 11 ,
@@ -945,32 +958,65 @@ public function saveWithLinksDataProvider()
945
958
// Scenario 1
946
959
// No existing, new links
947
960
$ data ['scenario_1 ' ] = [
948
- 'newLinks ' => ["product_sku " => "Simple Product 1 " , "link_type " => "associated " , "linked_product_sku " =>
949
- "Simple Product 2 " , "linked_product_type " => "simple " , "position " => 0 , "qty " => 1 ],
961
+ 'newLinks ' => [
962
+ "product_sku " => "Simple Product 1 " ,
963
+ "link_type " => "associated " ,
964
+ "linked_product_sku " => "Simple Product 2 " ,
965
+ "linked_product_type " => "simple " ,
966
+ "position " => 0 ,
967
+ "qty " => 1 ,
968
+ ],
950
969
'existingLinks ' => [],
951
- 'expectedData ' => [["product_sku " => "Simple Product 1 " , "link_type " => "associated " , "linked_product_sku " =>
952
- "Simple Product 2 " , "linked_product_type " => "simple " , "position " => 0 , "qty " => 1 ]]
953
- ];
970
+ 'expectedData ' => [[
971
+ "product_sku " => "Simple Product 1 " ,
972
+ "link_type " => "associated " ,
973
+ "linked_product_sku " => "Simple Product 2 " ,
974
+ "linked_product_type " => "simple " ,
975
+ "position " => 0 ,
976
+ "qty " => 1 ,
977
+ ]],
978
+ ];
954
979
955
980
// Scenario 2
956
981
// Existing, no new links
957
982
$ data ['scenario_2 ' ] = [
958
983
'newLinks ' => [],
959
- 'existingLinks ' => ["product_sku " => "Simple Product 1 " , "link_type " => "related " , "linked_product_sku " =>
960
- "Simple Product 2 " , "linked_product_type " => "simple " , "position " => 0 ],
961
- 'expectedData ' => []
984
+ 'existingLinks ' => [
985
+ "product_sku " => "Simple Product 1 " ,
986
+ "link_type " => "related " ,
987
+ "linked_product_sku " => "Simple Product 2 " ,
988
+ "linked_product_type " => "simple " ,
989
+ "position " => 0 ,
990
+ ],
991
+ 'expectedData ' => [],
962
992
];
963
993
964
994
// Scenario 3
965
995
// Existing and new links
966
996
$ data ['scenario_3 ' ] = [
967
- 'newLinks ' => ["product_sku " => "Simple Product 1 " , "link_type " => "related " , "linked_product_sku " =>
968
- "Simple Product 2 " , "linked_product_type " => "simple " , "position " => 0 ],
969
- 'existingLinks ' => ["product_sku " => "Simple Product 1 " , "link_type " => "related " , "linked_product_sku " =>
970
- "Simple Product 3 " , "linked_product_type " => "simple " , "position " => 0 ],
997
+ 'newLinks ' => [
998
+ "product_sku " => "Simple Product 1 " ,
999
+ "link_type " => "related " ,
1000
+ "linked_product_sku " => "Simple Product 2 " ,
1001
+ "linked_product_type " => "simple " ,
1002
+ "position " => 0 ,
1003
+ ],
1004
+ 'existingLinks ' => [
1005
+ "product_sku " => "Simple Product 1 " ,
1006
+ "link_type " => "related " ,
1007
+ "linked_product_sku " => "Simple Product 3 " ,
1008
+ "linked_product_type " => "simple " ,
1009
+ "position " => 0 ,
1010
+ ],
971
1011
'expectedData ' => [
972
- ["product_sku " => "Simple Product 1 " , "link_type " => "related " , "linked_product_sku " =>
973
- "Simple Product 2 " , "linked_product_type " => "simple " , "position " => 0 ]]
1012
+ [
1013
+ "product_sku " => "Simple Product 1 " ,
1014
+ "link_type " => "related " ,
1015
+ "linked_product_sku " => "Simple Product 2 " ,
1016
+ "linked_product_type " => "simple " ,
1017
+ "position " => 0 ,
1018
+ ],
1019
+ ],
974
1020
];
975
1021
976
1022
return $ data ;
@@ -1143,7 +1189,6 @@ public function testSaveExistingWithMediaGalleryEntries()
1143
1189
->method ('setMediaAttribute ' )
1144
1190
->with ($ this ->initializedProductMock , ['image ' , 'small_image ' ], 'filename1 ' );
1145
1191
1146
-
1147
1192
$ this ->model ->save ($ this ->productMock );
1148
1193
$ this ->assertEquals ($ expectedResult , $ this ->initializedProductMock ->getMediaGallery ('images ' ));
1149
1194
}
0 commit comments