@@ -132,7 +132,7 @@ public function testSave()
132132 ['linkedProduct ' , false , null , false , $ linkedProductMock ],
133133 ]);
134134 $ 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 ' );
136136 $ entityMock ->expects ($ this ->exactly (1 ))->method ('getLinkType ' )->willReturn ('linkType ' );
137137 $ this ->linkTypeProvider ->expects ($ this ->once ())->method ('getLinkTypes ' )->willReturn (['linkType ' => $ typeId ]);
138138 $ this ->metadataPoolMock ->expects ($ this ->once ())->method ('getHydrator ' )->willReturn ($ this ->hydratorMock );
@@ -164,7 +164,7 @@ public function testSaveWithException()
164164 ['linkedProduct ' , false , null , false , $ linkedProductMock ],
165165 ]);
166166 $ 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 ' );
168168 $ entityMock ->expects ($ this ->exactly (1 ))->method ('getLinkType ' )->willReturn ('linkType ' );
169169 $ this ->linkTypeProvider ->expects ($ this ->once ())->method ('getLinkTypes ' )->willReturn (['linkType ' => $ typeId ]);
170170 $ this ->metadataPoolMock ->expects ($ this ->once ())->method ('getHydrator ' )->willReturn ($ this ->hydratorMock );
@@ -185,10 +185,21 @@ public function testSaveWithoutLinkedProductSku()
185185 $ this ->expectException ('Magento\Framework\Exception\NoSuchEntityException ' );
186186 $ this ->expectExceptionMessage ('The linked product SKU is invalid. Verify the data and try again. ' );
187187 $ entityMock = $ this ->createMock (\Magento \Catalog \Model \ProductLink \Link::class);
188+ $ entityMock ->expects ($ this ->any ())->method ('getSku ' )->willReturn ('sku1 ' );
188189 $ entityMock ->expects ($ this ->any ())->method ('getLinkedProductSku ' )->willReturn ('' );
189190 $ this ->model ->save ($ entityMock );
190191 }
191192
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+
192203 /**
193204 * Test method
194205 */
0 commit comments