/** * @test */ public function TestErrorWhenFileDoesNotExist() { /** * we want to test if and file is not found */ $csv = new Csv('invalidfile.csv'); $error = $csv->hasError(); $this->assertEquals($error["error"], true); }
* @author Ryan Spencer <*****@*****.**> */ require 'src/autoload.php'; use App\Lib\Csv; use App\Lib\Json; use App\Lib\Args; use App\Lib\Messages; date_default_timezone_set('Australia/Sydney'); $message = new Messages(); 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");