Replace unecessary states in Food factory

This commit is contained in:
Christopher C. Wells 2021-04-20 11:55:10 -07:00
parent 057433eb90
commit ebb07ffb7d
2 changed files with 5 additions and 56 deletions

View File

@ -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'
];
});
}
}

View File

@ -116,7 +116,7 @@ class NutrientsTest extends TestCase
[$foodInvalidUnit, 1, 'tsp'],
[$foodInvalidUnit, 1, 'tbsp'],
[$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 */
$foods = [
'tsp' => Food::factory()->tspServingUnit()->make(),
'tbsp' => Food::factory()->tbspServingUnit()->make(),
'cup' => Food::factory()->cupServingUnit()->make(),
'none' => Food::factory()->noServingUnit()->make(),
'tsp' => Food::factory()->make(['serving_unit' => 'tsp', 'serving_size' => 1]),
'tbsp' => Food::factory()->make(['serving_unit' => 'tbsp', 'serving_size' => 1]),
'cup' => Food::factory()->make(['serving_unit' => 'cup', 'serving_size' => 1]),
'none' => Food::factory()->make(['serving_unit' => null, 'serving_unit_name' => 'head']),
];
return [