Ejemplo n.º 1
0
 /**
  * @test
  */
 public function TestErrorWhenFileDoesNotExist()
 {
     /**
      * we want to test if and file is not found
      */
     $json = new Json('invalidfile.json');
     $error = $json->hasError();
     $this->assertEquals($error["error"], true);
 }
Ejemplo n.º 2
0
 if ($arguments->count() == 2) {
     $ingredients = new Csv($arguments->get(0));
     // check to see if there was any ingredients imported
     if (!$ingredients->count()) {
         $error = $ingredients->hasError();
         if ($error["error"]) {
             $message->add($error["message"]);
         } else {
             // order takeout
             $message->add("All ingredients are past their used by date, Order Takeout!");
         }
     } else {
         // import recipes
         $recipes = new Json($arguments->get(1));
         if (!$recipes->count()) {
             $error = $recipes->hasError();
             if ($error["error"]) {
                 $message->add($error["message"]);
             } else {
                 $message->add("No recipes found in file or JSON file is invalid");
             }
         } else {
             // valid files now it is time to search
             // sort ingredients by usedby date
             $ingredients->sort();
             foreach ($recipes->get() as $key => $recipe) {
                 $score = 0;
                 foreach ($recipe["ingredients"] as $recipeIngredient) {
                     $ingredientData = $ingredients->find($recipeIngredient["item"]);
                     if (is_array($ingredientData)) {
                         if ($ingredientData["amount"] >= $recipeIngredient["amount"]) {