Exemplo n.º 1
0
 public function testSetGetIngredient()
 {
     $ingredient = new Ingredient();
     $ingredient->setName('water')->setQty('100')->setUnit('litres')->setUsedByDate(NULL);
     $this->assertEquals($ingredient->getName(), 'water');
     $this->assertEquals($ingredient->getUnit(), 'litres');
     $this->assertEquals($ingredient->getUsedByDate(), NULL);
 }
 /**
  * Return an array of ingredients based on CSV dataset passed in
  * @param  Array $csv_rows array of CSV row data
  * @return Collection      array of ingredient objects
  */
 private static function getIngredientCollection($csv_rows)
 {
     $ingredients = new Collection();
     foreach ($csv_rows as $row) {
         // Ignore whitespace/eof chars
         if (empty(trim($row[0]))) {
             continue;
         }
         $ingredient = new Ingredient();
         $ingredient->setName($row[0])->setQty($row[1])->setUnit($row[2])->setUsedByDate(self::parseCSVDateFormat($row[3]));
         $ingredients->put($ingredient->getName(), $ingredient);
     }
     return $ingredients;
 }