@@ -132,7 +132,7 @@ public function testSave()
132
132
['linkedProduct ' , false , null , false , $ linkedProductMock ],
133
133
]);
134
134
$ entityMock ->expects ($ this ->any ())->method ('getLinkedProductSku ' )->willReturn ('linkedProduct ' );
135
- $ entityMock ->expects ($ this ->once ( ))->method ('getSku ' )->willReturn ('product ' );
135
+ $ entityMock ->expects ($ this ->exactly ( 2 ))->method ('getSku ' )->willReturn ('product ' );
136
136
$ entityMock ->expects ($ this ->exactly (1 ))->method ('getLinkType ' )->willReturn ('linkType ' );
137
137
$ this ->linkTypeProvider ->expects ($ this ->once ())->method ('getLinkTypes ' )->willReturn (['linkType ' => $ typeId ]);
138
138
$ this ->metadataPoolMock ->expects ($ this ->once ())->method ('getHydrator ' )->willReturn ($ this ->hydratorMock );
@@ -164,7 +164,7 @@ public function testSaveWithException()
164
164
['linkedProduct ' , false , null , false , $ linkedProductMock ],
165
165
]);
166
166
$ entityMock ->expects ($ this ->any ())->method ('getLinkedProductSku ' )->willReturn ('linkedProduct ' );
167
- $ entityMock ->expects ($ this ->once ( ))->method ('getSku ' )->willReturn ('product ' );
167
+ $ entityMock ->expects ($ this ->exactly ( 2 ))->method ('getSku ' )->willReturn ('product ' );
168
168
$ entityMock ->expects ($ this ->exactly (1 ))->method ('getLinkType ' )->willReturn ('linkType ' );
169
169
$ this ->linkTypeProvider ->expects ($ this ->once ())->method ('getLinkTypes ' )->willReturn (['linkType ' => $ typeId ]);
170
170
$ this ->metadataPoolMock ->expects ($ this ->once ())->method ('getHydrator ' )->willReturn ($ this ->hydratorMock );
@@ -185,10 +185,21 @@ public function testSaveWithoutLinkedProductSku()
185
185
$ this ->expectException ('Magento\Framework\Exception\NoSuchEntityException ' );
186
186
$ this ->expectExceptionMessage ('The linked product SKU is invalid. Verify the data and try again. ' );
187
187
$ entityMock = $ this ->createMock (\Magento \Catalog \Model \ProductLink \Link::class);
188
+ $ entityMock ->expects ($ this ->any ())->method ('getSku ' )->willReturn ('sku1 ' );
188
189
$ entityMock ->expects ($ this ->any ())->method ('getLinkedProductSku ' )->willReturn ('' );
189
190
$ this ->model ->save ($ entityMock );
190
191
}
191
192
193
+ public function testSaveWithoutProductSku ()
194
+ {
195
+ $ this ->expectException ('Magento\Framework\Exception\NoSuchEntityException ' );
196
+ $ this ->expectExceptionMessage ('ProductSku should be specified ' );
197
+ $ entityMock = $ this ->createMock (\Magento \Catalog \Model \ProductLink \Link::class);
198
+ $ entityMock ->expects ($ this ->any ())->method ('getSku ' )->willReturn ('' );
199
+ $ entityMock ->expects ($ this ->any ())->method ('getLinkedProductSku ' )->willReturn ('linkedProductSku ' );
200
+ $ this ->model ->save ($ entityMock );
201
+ }
202
+
192
203
/**
193
204
* Test method
194
205
*/
0 commit comments