/**
  * Check if the recipe ingredient qty is available in the
  * ridge or not.
  *
  * @param  Ingredient $contestant [description]
  * @return boolean                return TRUE if qty can be met, FALSE if not
  */
 public function isSatisfiedBy($contestant)
 {
     $qty_available = 0;
     if ($this->usable_ingredients->count()) {
         if ($this->usable_ingredients->get($contestant->getName())) {
             $qty_available = $this->usable_ingredients->get($contestant->getName())->getQty();
         }
     }
     if ($contestant->getQty() <= $qty_available) {
         return TRUE;
     }
     $this->addMessage('INGREDIENTS', 'Required amount of ingredients is not available in the fridge.');
     return FALSE;
 }
Exemplo n.º 2
0
 public function testSetGetIngredient()
 {
     $ingredient = new Ingredient();
     $ingredient->setName('water')->setQty('100')->setUnit('litres')->setUsedByDate(NULL);
     $this->assertEquals($ingredient->getName(), 'water');
     $this->assertEquals($ingredient->getUnit(), 'litres');
     $this->assertEquals($ingredient->getUsedByDate(), NULL);
 }
 /**
  * Check if an ingredient is in the fridge or not.
  *
  * @param  Ingredient $contestant [description]
  * @return boolean                return TRUE if in the fridge or FALSE if not
  */
 public function isSatisfiedBy($contestant)
 {
     if ($this->ingredient_repository->findByName($contestant->getName())) {
         return TRUE;
     }
     $this->addMessage('INGREDIENTS', 'Ingredient required for the recipe is not in the fridge.');
     return FALSE;
 }