@@ -133,20 +133,29 @@ public function testGetStockQtyLeft()
133
133
$ storeMock = $ this ->getMockBuilder (Store::class)
134
134
->disableOriginalConstructor ()
135
135
->getMock ();
136
+ $ product = $ this ->createMock (Product::class);
137
+ $ product ->expects ($ this ->once ())
138
+ ->method ('getStore ' )
139
+ ->willReturn ($ storeMock );
136
140
$ storeMock ->expects ($ this ->once ())
137
141
->method ('getWebsiteId ' )
138
142
->willReturn ($ websiteId );
139
- $ product = $ this ->createMock (Product::class);
140
143
$ product ->expects ($ this ->any ())
141
144
->method ('getId ' )
142
145
->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 ())
147
147
->method ('registry ' )
148
148
->with ('current_product ' )
149
149
->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
+ }
150
159
151
160
$ stockItemMock = $ this ->getMockBuilder (StockItemInterface::class)
152
161
->disableOriginalConstructor ()
0 commit comments