Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function isStockSufficient(StockableInterface $stockable, $quantity)
 {
     if (true === $this->backorders || $stockable->isAvailableOnDemand()) {
         return true;
     }
     return $quantity <= $stockable->getOnHand() - $stockable->getOnHold();
 }
 /**
  * {@inheritdoc}
  */
 public function isStockSufficient(StockableInterface $stockable, $quantity)
 {
     if ($stockable instanceof SoftDeletableInterface && $stockable->isDeleted()) {
         return false;
     }
     if ($this->backorders || $stockable->isAvailableOnDemand()) {
         return true;
     }
     return $quantity <= $stockable->getOnHand() - $stockable->getOnHold();
 }
 function it_recognizes_stock_sufficient_if_its_available_on_demand_and_backorders_are_disabled(StockableInterface $stockable)
 {
     $this->beConstructedWith(false);
     $stockable->isAvailableOnDemand()->willReturn(true);
     $stockable->getOnHand()->willReturn(0);
     $this->isStockSufficient($stockable, 999)->shouldReturn(true);
     $stockable->getOnHand()->willReturn(-5);
     $this->isStockSufficient($stockable, 3)->shouldReturn(true);
 }