mirror of https://github.com/kcal-app/kcal.git
Replace unecessary states in Food factory
This commit is contained in:
parent
057433eb90
commit
ebb07ffb7d
|
|
@ -39,55 +39,4 @@ class FoodFactory extends Factory
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Define a "tsp" serving unit.
|
|
||||||
*/
|
|
||||||
public function tspServingUnit()
|
|
||||||
{
|
|
||||||
return $this->state(function (array $attributes) {
|
|
||||||
return [
|
|
||||||
'serving_unit' => 'tsp',
|
|
||||||
'serving_size' => 1,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define a "tbsp" serving unit.
|
|
||||||
*/
|
|
||||||
public function tbspServingUnit()
|
|
||||||
{
|
|
||||||
return $this->state(function (array $attributes) {
|
|
||||||
return [
|
|
||||||
'serving_unit' => 'tbsp',
|
|
||||||
'serving_size' => 1,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define a "cup" serving unit.
|
|
||||||
*/
|
|
||||||
public function cupServingUnit()
|
|
||||||
{
|
|
||||||
return $this->state(function (array $attributes) {
|
|
||||||
return [
|
|
||||||
'serving_unit' => 'cup',
|
|
||||||
'serving_size' => 1,
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Define no serving unit.
|
|
||||||
*/
|
|
||||||
public function noServingUnit()
|
|
||||||
{
|
|
||||||
return $this->state(function (array $attributes) {
|
|
||||||
return [
|
|
||||||
'serving_unit' => null,
|
|
||||||
'serving_unit_name' => 'head'
|
|
||||||
];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class NutrientsTest extends TestCase
|
||||||
[$foodInvalidUnit, 1, 'tsp'],
|
[$foodInvalidUnit, 1, 'tsp'],
|
||||||
[$foodInvalidUnit, 1, 'tbsp'],
|
[$foodInvalidUnit, 1, 'tbsp'],
|
||||||
[$foodInvalidUnit, 1, 'cup'],
|
[$foodInvalidUnit, 1, 'cup'],
|
||||||
[Food::factory()->tspServingUnit()->make(), 1, 'invalid'],
|
[Food::factory()->make(['serving_unit' => 'tsp', 'serving_size' => 1]), 1, 'invalid'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,10 +128,10 @@ class NutrientsTest extends TestCase
|
||||||
|
|
||||||
/** @var \App\Models\Food[] $foods */
|
/** @var \App\Models\Food[] $foods */
|
||||||
$foods = [
|
$foods = [
|
||||||
'tsp' => Food::factory()->tspServingUnit()->make(),
|
'tsp' => Food::factory()->make(['serving_unit' => 'tsp', 'serving_size' => 1]),
|
||||||
'tbsp' => Food::factory()->tbspServingUnit()->make(),
|
'tbsp' => Food::factory()->make(['serving_unit' => 'tbsp', 'serving_size' => 1]),
|
||||||
'cup' => Food::factory()->cupServingUnit()->make(),
|
'cup' => Food::factory()->make(['serving_unit' => 'cup', 'serving_size' => 1]),
|
||||||
'none' => Food::factory()->noServingUnit()->make(),
|
'none' => Food::factory()->make(['serving_unit' => null, 'serving_unit_name' => 'head']),
|
||||||
];
|
];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue