public function testFillFromArrayFunction() { $testData = array(0 => array(0 => 'bread', 1 => '10', 2 => 'slices', 3 => date_format(new DateTime('+365 days'), 'd/m/Y')), 1 => array(0 => 'cheese', 1 => '10', 2 => 'slices', 3 => date_format(new DateTime('+365 days'), 'd/m/Y'))); $fridge = new Fridge(); $fridge->fillFromArray($testData); $items = $fridge->getItems(); $this->assertEquals($items[0]->getItem(), $testData[0][0]); $this->assertEquals($items[1]->getItem(), $testData[1][0]); $this->assertEquals(sizeof($items), 2); }
function main() { $fridge_csv_path = isset($argv[1]) ? $argv[1] : 'fridge.csv'; $recipe_json_path = isset($argv[2]) ? $argv[2] : 'recipes.js'; $ingredients = array_map('str_getcsv', file($fridge_csv_path)); $recipes = json_decode(file_get_contents($recipe_json_path), 1); $fridge = new Fridge(); $fridge->fillFromArray($ingredients); $finder = new Finder($fridge); $recipeToday = $finder->findRecipe($recipes); echo $recipeToday . "\n"; }