/**
  * @param Sylius\Bundle\InventoryBundle\Model\StockableInterface     $stockable
  * @param Sylius\Bundle\InventoryBundle\Model\InventoryUnitInterface $inventoryUnit1
  * @param Sylius\Bundle\InventoryBundle\Model\InventoryUnitInterface $inventoryUnit2
  * @param Doctrine\Common\Persistence\ObjectRepository               $repository
  */
 function it_should_fill_backorder_units($stockable, $inventoryUnit1, $inventoryUnit2, $repository)
 {
     $stockable->getOnHand()->shouldBeCalled()->willReturn(1);
     $inventoryUnit1->setInventoryState(InventoryUnitInterface::STATE_SOLD)->shouldBeCalled();
     $inventoryUnit2->setInventoryState(InventoryUnitInterface::STATE_SOLD)->shouldNotBeCalled();
     $repository->findBy(ANY_ARGUMENTS)->willReturn(array($inventoryUnit1, $inventoryUnit2));
     $this->fillBackorders($stockable);
 }
Ejemplo n.º 2
0
 /**
  * Delete
  *
  * @param integer $id
  */
 public function delete($id)
 {
     $record = $this->repository->find($id);
     if (!$record) {
         throw new NotFoundHttpException('Unable to find Redirect entity.');
     }
     $this->om->remove($record);
     $this->om->flush();
 }
Ejemplo n.º 3
0
 /**
  * Save feed
  *
  * @param array $values
  * @return Newscoop\News\Feed
  */
 public function save(array $values)
 {
     if (!array_key_exists('type', $values)) {
         throw new \InvalidArgumentException("Feed type not specified");
     }
     $feed = $this->repository->findBy($values);
     if (count($feed)) {
         return $feed[0];
     }
     switch ($values['type']) {
         case 'reuters':
             $feed = new ReutersFeed($values['config']);
             break;
         default:
             throw new \InvalidArgumentException("Feed type '{$values['type']}' not implemented");
     }
     $this->om->persist($feed);
     $this->om->flush();
     return $feed;
 }