/** * @param $foodItem * @param $expectedException * @dataProvider exceptionDataProvider */ public function testExceptions($foodItem, $expectedException) { try { $this->fridge->check($foodItem); $this->fail('Failed to throw expected exception: ' . $expectedException); } catch (\Exception $e) { $this->assertEquals($expectedException, get_class($e)); } }
/** * 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; }