@@ -200,6 +200,21 @@ public function testCheckQty(StockItemInterface $stockItem, $expectedResult)
200200 );
201201 }
202202
203+ /**
204+ * Check quantity with out-of-stock status but positive or 0 quantity.
205+ *
206+ * @param StockItemInterface $stockItem
207+ * @param mixed $expectedResult
208+ * @dataProvider checkQtyWithStockStatusDataProvider
209+ */
210+ public function testCheckQtyWithPositiveQtyAndOutOfStockstatus (StockItemInterface $ stockItem , $ expectedResult )
211+ {
212+ $ this ->assertEquals (
213+ $ expectedResult ,
214+ $ this ->stockStateProvider ->checkQty ($ stockItem , $ this ->qty )
215+ );
216+ }
217+
203218 /**
204219 * @param StockItemInterface $stockItem
205220 * @param mixed $expectedResult
@@ -281,6 +296,14 @@ public function checkQtyDataProvider()
281296 return $ this ->prepareDataForMethod ('checkQty ' );
282297 }
283298
299+ /**
300+ * @return array
301+ */
302+ public function checkQtyWithStockStatusDataProvider ()
303+ {
304+ return $ this ->prepareDataForMethod ('checkQty ' , $ this ->getVariationsForQtyAndStock ());
305+ }
306+
284307 /**
285308 * @return array
286309 */
@@ -315,12 +338,16 @@ public function checkQuoteItemQtyDataProvider()
315338
316339 /**
317340 * @param $methodName
341+ * @param array|null $options
318342 * @return array
319343 */
320- protected function prepareDataForMethod ($ methodName )
344+ protected function prepareDataForMethod ($ methodName, array $ options = null )
321345 {
322346 $ variations = [];
323- foreach ($ this ->getVariations () as $ variation ) {
347+ if ($ options === null ) {
348+ $ options = $ this ->getVariations ();
349+ }
350+ foreach ($ options as $ variation ) {
324351 $ stockItem = $ this ->getMockBuilder (StockItemInterface::class)
325352 ->disableOriginalConstructor ()
326353 ->setMethods ($ this ->stockItemMethods )
@@ -360,7 +387,7 @@ protected function prepareDataForMethod($methodName)
360387 /**
361388 * @return array
362389 */
363- protected function getVariations ()
390+ private function getVariations ()
364391 {
365392 $ stockQty = 100 ;
366393 return [
@@ -448,6 +475,58 @@ protected function getVariations()
448475 ];
449476 }
450477
478+ /**
479+ * @return array
480+ */
481+ private function getVariationsForQtyAndStock ()
482+ {
483+ $ stockQty = 100 ;
484+ return [
485+ [
486+ 'values ' => [
487+ 'getIsInStock ' => false ,
488+ 'getQty ' => $ stockQty ,
489+ 'getMinQty ' => 60 ,
490+ 'getMinSaleQty ' => 1 ,
491+ 'getMaxSaleQty ' => 99 ,
492+ 'getNotifyStockQty ' => 101 ,
493+ 'getManageStock ' => true ,
494+ 'getBackorders ' => 0 ,
495+ 'getQtyIncrements ' => 1 ,
496+ '_stock_qty_ ' => null ,
497+ '_suppress_check_qty_increments_ ' => false ,
498+ '_is_saleable_ ' => true ,
499+ '_ordered_items_ ' => 0 ,
500+ '_product_ ' => 'Test product Name ' ,
501+ ],
502+ 'results ' => [
503+ 'checkQty ' => false
504+ ]
505+ ],
506+ [
507+ 'values ' => [
508+ 'getIsInStock ' => false ,
509+ 'getQty ' => 0 ,
510+ 'getMinQty ' => 60 ,
511+ 'getMinSaleQty ' => 1 ,
512+ 'getMaxSaleQty ' => 99 ,
513+ 'getNotifyStockQty ' => 101 ,
514+ 'getManageStock ' => true ,
515+ 'getBackorders ' => 0 ,
516+ 'getQtyIncrements ' => 1 ,
517+ '_stock_qty_ ' => null ,
518+ '_suppress_check_qty_increments_ ' => false ,
519+ '_is_saleable_ ' => true ,
520+ '_ordered_items_ ' => 0 ,
521+ '_product_ ' => 'Test product Name ' ,
522+ ],
523+ 'results ' => [
524+ 'checkQty ' => false
525+ ]
526+ ]
527+ ];
528+ }
529+
451530 /**
452531 * @param bool $isChildItem
453532 * @param string $expectedMsg
0 commit comments