Пример #1
0
 /**
  * @test
  */
 public function TestResultsValid()
 {
     /**
      * we want to make sure an array is returned
      */
     $json = new Json('./resources/recipes.json');
     $this->assertEquals(is_array($json->get()), true);
 }
Пример #2
0
if (isset($argv)) {
    $arguments = new Args($argv);
    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"]);