Example #1
0
 /**
  * @param FoodItems $ingredients
  * @param $matchingItemNames
  * @dataProvider getMatchingItemsDataProvider
  */
 public function testGetMatchingItems(FoodItems $ingredients, $matchingItemNames)
 {
     $fridgeItems = $this->fridge->getMatchingItems($ingredients);
     if ($matchingItemNames === false) {
         $this->assertEquals($matchingItemNames, $fridgeItems);
     } else {
         $this->assertEquals($matchingItemNames, $fridgeItems->itemNames());
     }
 }
Example #2
0
 /**
  * Iterates through all recipes and returns an array of recipes
  * that we have all ingredients for.
  *
  * Returns an associative array with
  *  recipe name => timestamp for item with closest use by
  *
  * @return array
  */
 public function findValid()
 {
     $validRecipes = array();
     /** @var Recipe $recipe */
     foreach ($this->recipes as $name => $recipe) {
         if (($fridgeItems = $this->fridge->getMatchingItems($recipe->getIngredients())) !== false) {
             $validRecipes[$name] = $fridgeItems->getNearestUseBy();
         }
     }
     return $validRecipes;
 }