/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $seafoods = ['fish', 'anchovy', 'basa', 'bass', 'cod', 'bream', 'brill', 'eel', 'herring', 'pike', 'pollock', 'salmon', 'sardine', 'shark', 'snapper', 'tilapia', 'trout', 'tuna', 'whiting', 'caviar', 'crab', 'lobster', 'shrimp', 'mollusc', 'conch', 'mussel', 'octopus', 'oyster', 'scallop', 'squid', 'sea'];
     $seaFoodsArray = array();
     //Retrieve all foods with nut in the name. Super rudimentary way to filter, but this will just show that the API works.
     foreach ($seafoods as $seafood) {
         $seaFoodsArray = array_merge($seaFoodsArray, \App\Food::GetNameSimilarTo($seafood)->lists('id')->toArray());
     }
     $seaFoodsArray = array_unique($seaFoodsArray);
     $restriction = App\Restriction::find(2);
     $restriction->restrictedFoods()->attach($seaFoodsArray);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $dairys = ['milk', 'dairy', 'yogurt', 'butter', 'cheese', 'casein', 'clabber', 'gelato', 'cream', 'custard', 'brick', 'brie', 'camembert', 'cheddar', 'chesire', 'colby', 'coldpack', 'edam', 'feta'];
     $dairysArray = array();
     //Retrieve all foods with nut in the name. Super rudimentary way to filter, but this will just show that the API works.
     foreach ($dairys as $dairy) {
         $dairysArray = array_merge($dairysArray, \App\Food::GetNameSimilarTo($dairy)->lists('id')->toArray());
     }
     $dairysArray = array_unique($dairysArray);
     $restriction = App\Restriction::find(3);
     $restriction->restrictedFoods()->attach($dairysArray);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $nuts = ['acorn', 'cashew', 'pecan', 'nut', 'almond', 'pistachio'];
     $nutFoodsArray = array();
     //Retrieve all foods with nut in the name. Super rudimentary way to filter, but this will just show that the API works.
     foreach ($nuts as $nut) {
         $nutFoodsArray = array_merge($nutFoodsArray, \App\Food::GetNameSimilarTo($nut)->lists('id')->toArray());
     }
     $nutFoodsArray = array_unique($nutFoodsArray);
     $restriction = App\Restriction::find(1);
     $restriction->restrictedFoods()->attach($nutFoodsArray);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $chocolates = ['chocolate', 'cocoa'];
     $chocolatesArray = array();
     //Retrieve all foods with nut in the name. Super rudimentary way to filter, but this will just show that the API works.
     foreach ($chocolates as $chocolate) {
         $chocolatesArray = array_merge($chocolatesArray, \App\Food::GetNameSimilarTo($chocolate)->lists('id')->toArray());
     }
     $chocolatesArray = array_unique($chocolatesArray);
     $restriction = App\Restriction::find(5);
     $restriction->restrictedFoods()->attach($chocolatesArray);
 }
 public function testRestrictions()
 {
     $user = $this->spawnUser();
     $r = App\Restriction::all()[0];
     $user->addRestriction($r);
     $this->assertEquals($user->addRestriction($r), null);
     $this->assertEquals($r->getDisplayName(), "Nut Allergy");
     //Spawns food and detaches + reattaches restriction
     $f = App\Food::GetNameSimilarTo("nuts", [])[0];
     App\Food::ObeyRestrictions($r);
     $this->assertEquals(App\Food::ObeyRestrictions($r), null);
     if ($f->isRestricted($r)) {
         $f->removeRestriction($r);
         $this->assertEquals($f->removeRestriction($r), null);
         $this->assertEquals($f->isRestricted($r), false);
     }
     $f->addRestriction($r);
     $this->assertEquals($user->canEatFood($f), false);
     $this->assertEquals($f->isRestricted($r), true);
     $sample1 = $user->getFoodSuggestion();
     $sample2 = $user->getFoodSuggestion();
     $this->assertNotEquals($sample1, $sample2);
     $this->assertEquals($user->canEatFood($sample1), true);
 }
 public function testFoodCreation()
 {
     $food = Food::GetNameSimilarTo("apple")[0];
     $this->assertEquals("Babyfood, apples, dices, toddler", $food->getName());
     $this->assertEquals("3115", $food->getId());
     // 51 calories
     $this->assertEquals("51", $food->getCalories());
     // 0.0 caffiene
     $this->assertEquals("0.0", $food->getCaffeine());
     $this->assertEquals("mg", $food->getCaffieneUnits());
     // 0.02 mg copper
     $this->assertEquals("0.02", $food->getCopper());
     $this->assertEquals("mg", $food->getCopperUnits());
     // 0.1 g fat
     $this->assertEquals("0.1", $food->getFat());
     $this->assertEquals("g", $food->getFatUnits());
     // 0.9 g fiber
     $this->assertEquals("0.9", $food->getFiber());
     $this->assertEquals("g", $food->getFiberUnits());
     // 0.2 mg iron
     $this->assertEquals("0.2", $food->getIron());
     $this->assertEquals("mg", $food->getIronUnits());
     // 6.0 mg magnesium
     $this->assertEquals("6.0", $food->getMagnesium());
     $this->assertEquals("mg", $food->getMagnesiumUnits());
     // 13.0 mg phosphorus
     $this->assertEquals("13.0", $food->getPhosphorus());
     $this->assertEquals("mg", $food->getPhosphorusUnits());
     // 0.04 mg manganese
     $this->assertEquals("0.04", $food->getManganese());
     $this->assertEquals("mg", $food->getManganeseUnits());
     // 0 mg potassium
     $this->assertEquals("0", $food->getPotassium());
     $this->assertEquals("mg", $food->getPotassiumUnits());
     // 0 mg sodium
     $this->assertEquals("0", $food->getSodium());
     $this->assertEquals("mg", $food->getSodiumUnits());
     // 10.0 calcium
     $this->assertEquals("10.0", $food->getCalcium());
     // Calcium unit: mg
     $this->assertEquals("mg", $food->getCalciumUnits());
     // 12.1 carbohydrates
     $this->assertEquals("12.1", $food->getCarbohydrates());
     // Carbohydrates units: g
     $this->assertEquals("g", $food->getCarbohydratesUnits());
     // 0.2g protein
     $this->assertEquals("0.2", $food->getProtein());
     $this->assertEquals("g", $food->getProteinUnits());
     // 10.83g sugar
     $this->assertEquals("10.83", $food->getSugar());
     $this->assertEquals("g", $food->getSugarUnits());
     // 2.0 ug vitamin a
     $this->assertEquals("2.0", $food->getVitaminA());
     $this->assertEquals("ug", $food->getVitaminAUnits());
     // 0.0 ug vitamin b12
     $this->assertEquals("0.0", $food->getVitaminB12());
     $this->assertEquals("ug", $food->getVitaminB12Units());
     // 0.05 mg vitamin b6
     $this->assertEquals("0.05", $food->getVitaminB6());
     $this->assertEquals("mg", $food->getVitaminB6Units());
     // 31.3 mg vitamin c
     $this->assertEquals("31.3", $food->getVitaminC());
     $this->assertEquals("mg", $food->getVitaminCUnits());
     // 0.0 ug vitamin d
     $this->assertEquals("0.0", $food->getVitaminD());
     $this->assertEquals("ug", $food->getVitaminDUnits());
     // 0.23 mg vitamin e
     $this->assertEquals("0.23", $food->getVitaminE());
     $this->assertEquals("mg", $food->getVitaminEUnits());
     // 0.6 ug vitamin k
     $this->assertEquals("0.6", $food->getVitaminK());
     $this->assertEquals("ug", $food->getVitaminKUnits());
     // 0.04 mg zinc
     $this->assertEquals("0.04", $food->getZinc());
     $this->assertEquals("mg", $food->getZincUnits());
 }