@@ -133,20 +133,29 @@ public function testGetStockQtyLeft()
133133 $ storeMock = $ this ->getMockBuilder (Store::class)
134134 ->disableOriginalConstructor ()
135135 ->getMock ();
136+ $ product = $ this ->createMock (Product::class);
137+ $ product ->expects ($ this ->once ())
138+ ->method ('getStore ' )
139+ ->willReturn ($ storeMock );
136140 $ storeMock ->expects ($ this ->once ())
137141 ->method ('getWebsiteId ' )
138142 ->willReturn ($ websiteId );
139- $ product = $ this ->createMock (Product::class);
140143 $ product ->expects ($ this ->any ())
141144 ->method ('getId ' )
142145 ->willReturn ($ productId );
143- $ product ->expects ($ this ->once ())
144- ->method ('getStore ' )
145- ->willReturn ($ storeMock );
146- $ this ->registryMock ->expects ($ this ->once ())
146+ $ this ->registryMock ->expects ($ this ->any ())
147147 ->method ('registry ' )
148148 ->with ('current_product ' )
149149 ->willReturn ($ product );
150+ if ($ productId ) {
151+ $ stockStatus = $ this ->getMockBuilder (StockStatusInterface::class)
152+ ->getMockForAbstractClass ();
153+ $ stockStatus ->expects ($ this ->any ())->method ('getQty ' )->willReturn ($ stockQty );
154+ $ this ->stockRegistryMock ->expects ($ this ->once ())
155+ ->method ('getStockStatus ' )
156+ ->with ($ productId , $ websiteId )
157+ ->willReturn ($ stockStatus );
158+ }
150159
151160 $ stockItemMock = $ this ->getMockBuilder (StockItemInterface::class)
152161 ->disableOriginalConstructor ()
0 commit comments