feat(seeders): add IncoSheet and IncoCompo seeders
Implement seeders for IncoSheet and IncoCompo to populate the database with initial data.
This commit is contained in:
parent
3080c5dcfe
commit
1d55dff5f4
12 changed files with 623 additions and 5 deletions
213
database/factories/IncoCompoFactory.php
Normal file
213
database/factories/IncoCompoFactory.php
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Infra\Database\Models\IncoCompo;
|
||||
|
||||
/**
|
||||
* @extends Factory<IncoCompo>
|
||||
*/
|
||||
final class IncoCompoFactory extends Factory
|
||||
{
|
||||
protected $model = IncoCompo::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[\Override]
|
||||
public function definition(): array
|
||||
{
|
||||
$idInco = (string) fake()->unique()->numberBetween(10000, 99999);
|
||||
|
||||
return [
|
||||
'id' => $idInco,
|
||||
'id_inco' => $idInco,
|
||||
'identification' => [
|
||||
'name' => 'Poulet Rôti 1kg',
|
||||
'number' => $idInco,
|
||||
'source' => 'LDC',
|
||||
],
|
||||
'energy' => [
|
||||
'reference' => ['size' => '100g', 'energyKj' => '500', 'energyKcal' => '120'],
|
||||
'portion' => ['size' => '150g', 'energyKj' => '750', 'energyKcal' => '180'],
|
||||
],
|
||||
'reference_macronutrients' => [
|
||||
'fat' => ['amount' => '10.0', 'precision' => null],
|
||||
'saturatedFat' => ['amount' => '2.5', 'precision' => null],
|
||||
'carbohydrates' => ['amount' => '0.5', 'precision' => null],
|
||||
'sugars' => ['amount' => '0.1', 'precision' => null],
|
||||
'fiber' => ['amount' => '0.0', 'precision' => null],
|
||||
'protein' => ['amount' => '22.0', 'precision' => null],
|
||||
'salt' => ['amount' => '1.2', 'precision' => null],
|
||||
'sodium' => '0.48',
|
||||
],
|
||||
'portion_macronutrients' => [
|
||||
'fat' => ['amount' => '15.0', 'precision' => null],
|
||||
'saturatedFat' => ['amount' => '3.75', 'precision' => null],
|
||||
'carbohydrates' => ['amount' => '0.75', 'precision' => null],
|
||||
'sugars' => ['amount' => '0.15', 'precision' => null],
|
||||
'fiber' => ['amount' => '0.0', 'precision' => null],
|
||||
'protein' => ['amount' => '33.0', 'precision' => null],
|
||||
'salt' => ['amount' => '1.8', 'precision' => null],
|
||||
'sodium' => '0.72',
|
||||
],
|
||||
'fresh_produce_and_nuts' => [
|
||||
'reference' => ['fruits' => '0', 'nuts' => '0'],
|
||||
'portion' => ['fruits' => '0', 'nuts' => '0'],
|
||||
'freshFnlPercentage' => ['value' => '0'],
|
||||
'fruitsPercentage' => ['value' => '0'],
|
||||
],
|
||||
'reference_intakes' => [
|
||||
'energyE14' => ['value' => '6%'],
|
||||
'energyKj' => ['value' => '6%'],
|
||||
'fat' => ['value' => '14%'],
|
||||
'saturatedFat' => ['value' => '13%'],
|
||||
'carbohydrates' => ['value' => '0%'],
|
||||
'sugars' => ['value' => '0%'],
|
||||
'protein' => ['value' => '44%'],
|
||||
'salt' => ['value' => '20%'],
|
||||
'portionAmount' => '150g',
|
||||
'proteinToLipidRatio' => '2.2',
|
||||
],
|
||||
'nutri_score' => [
|
||||
'class' => 'A',
|
||||
'score' => -2,
|
||||
'isFnl' => false,
|
||||
'status' => 'valid',
|
||||
],
|
||||
'nutri_score_points' => [
|
||||
'energyPoints' => '1',
|
||||
'saturatedFatPoints' => '1',
|
||||
'sugarsPoints' => '0',
|
||||
'saltPoints' => '2',
|
||||
'fiberPoints' => '0',
|
||||
'proteinPoints' => '5',
|
||||
'freshFnlPoints' => '0',
|
||||
],
|
||||
'minerals' => [
|
||||
'calcium' => '12.0',
|
||||
'magnesium' => '25.0',
|
||||
'potassium' => '300.0',
|
||||
'phosphorus' => '200.0',
|
||||
'chloride' => '0.0',
|
||||
'iron' => '1.1',
|
||||
'zinc' => '1.5',
|
||||
'copper' => '0.1',
|
||||
'manganese' => '0.0',
|
||||
'selenium' => '15.0',
|
||||
'iodine' => '0.0',
|
||||
'chromium' => '0.0',
|
||||
'molybdenum' => '0.0',
|
||||
'sulfur' => '0.0',
|
||||
'nitrates' => '0.0',
|
||||
],
|
||||
'vitamins' => [
|
||||
'vitaminA' => '0.0',
|
||||
'vitaminB6' => '0.4',
|
||||
'vitaminB12' => '0.5',
|
||||
'vitaminC' => '0.0',
|
||||
'vitaminD' => '0.0',
|
||||
'vitaminE' => '0.2',
|
||||
'vitaminK' => '0.0',
|
||||
'cholecalciferol' => '0.0',
|
||||
'niacin' => '8.0',
|
||||
'riboflavin' => '0.2',
|
||||
'thiamine' => '0.1',
|
||||
'pantothenicAcid' => '1.0',
|
||||
'biotin' => '0.0',
|
||||
'folates' => '10.0',
|
||||
],
|
||||
'carbohydrates_detail' => [
|
||||
'starch' => '0.0',
|
||||
'maltodextrin' => '0.0',
|
||||
'sucrose' => '0.0',
|
||||
'glucose' => '0.0',
|
||||
'lactose' => '0.0',
|
||||
'maltose' => '0.0',
|
||||
'galactose' => '0.0',
|
||||
'carbohydrateHydrates' => '0.0',
|
||||
'boundFructose' => '0.0',
|
||||
'freeFructose' => '0.0',
|
||||
'oligosaccharides' => '0.0',
|
||||
'polyols' => '0.0',
|
||||
'solubleFiber' => '0.0',
|
||||
'inositol' => '0.0',
|
||||
],
|
||||
'fatty_acids' => [
|
||||
'fd' => '0.0',
|
||||
'cholesterol' => '70.0',
|
||||
'transFat' => '0.1',
|
||||
'formic' => '0.0',
|
||||
'acetic' => '0.0',
|
||||
'propionic' => '0.0',
|
||||
'butyric' => '0.0',
|
||||
'valeric' => '0.0',
|
||||
'caproic' => '0.0',
|
||||
'enanthic' => '0.0',
|
||||
'caprylic' => '0.0',
|
||||
'pelargonic' => '0.0',
|
||||
'capric' => '0.0',
|
||||
'undecylic' => '0.0',
|
||||
'lauric' => '0.0',
|
||||
'tridecylic' => '0.0',
|
||||
'myristic' => '0.1',
|
||||
'pentadecylic' => '0.0',
|
||||
'f16d0' => '0.0',
|
||||
'margaric' => '0.0',
|
||||
'stearic' => '0.8',
|
||||
'arachidic' => '0.0',
|
||||
'heneicosylic' => '0.0',
|
||||
'behenic' => '0.0',
|
||||
'tricosylic' => '0.0',
|
||||
'lignoceric' => '0.0',
|
||||
'carboceric' => '0.0',
|
||||
'cerotic' => '0.0',
|
||||
'ceroplastic' => '0.0',
|
||||
'montanic' => '0.0',
|
||||
'nonacosylic' => '0.0',
|
||||
'melissic' => '0.0',
|
||||
'laceric' => '0.0',
|
||||
'hentriacontylic' => '0.0',
|
||||
'hextriacontylic' => '0.0',
|
||||
'heptatriacontylic' => '0.0',
|
||||
'octatriacontylic' => '0.0',
|
||||
'nonadylie' => '0.0',
|
||||
'psyllic' => '0.0',
|
||||
'palmitic' => '1.5',
|
||||
'oleic' => '2.0',
|
||||
'f18d' => '0.0',
|
||||
'f19d' => '0.0',
|
||||
'f11eico' => '0.0',
|
||||
'geddic' => '0.0',
|
||||
'erucic' => '0.0',
|
||||
'nervonic' => '0.0',
|
||||
'hyenic' => '0.0',
|
||||
'amscis' => '0.0',
|
||||
'f18d2cn6' => '0.5',
|
||||
'f18d3n3' => '0.1',
|
||||
'f20d4' => '0.0',
|
||||
'f20d5n3' => '0.0',
|
||||
'f22d6n3' => '0.0',
|
||||
'fapun3' => '0.0',
|
||||
'fapun6' => '0.0',
|
||||
'fapun9' => '0.0',
|
||||
'fapucis' => '0.0',
|
||||
'fapulc' => '0.0',
|
||||
],
|
||||
'amino_acids' => [
|
||||
'essentialAminoAcids' => '8.5',
|
||||
'caseins' => '0.0',
|
||||
'wheyProtein' => '0.0',
|
||||
],
|
||||
'special_compounds' => [
|
||||
'choline' => '60.0',
|
||||
'carnitine' => '5.0',
|
||||
'taurine' => '0.0',
|
||||
'nucleotides' => '0.0',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
71
database/factories/IncoSheetFactory.php
Normal file
71
database/factories/IncoSheetFactory.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Infra\Database\Models\IncoSheet;
|
||||
|
||||
/**
|
||||
* @extends Factory<IncoSheet>
|
||||
*/
|
||||
final class IncoSheetFactory extends Factory
|
||||
{
|
||||
protected $model = IncoSheet::class;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
#[\Override]
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'id' => (string) fake()->unique()->numberBetween(10000, 99999),
|
||||
'name' => 'Poulet Rôti 1kg',
|
||||
'label' => 'Poulet Rôti Classe A',
|
||||
'description' => 'Poulet prêt à cuire élevé en France',
|
||||
'allegations' => [
|
||||
'allegations' => ['Volaille française'],
|
||||
'health' => [],
|
||||
'nutrition' => ['Riche en protéines'],
|
||||
'other' => [],
|
||||
],
|
||||
'sell_arguments' => 'Origine France garantie',
|
||||
'preparation_advices' => 'Cuisson au four 1h à 180°C',
|
||||
'tips' => 'Servir chaud',
|
||||
'sell_familly' => 'Volaille',
|
||||
'ingredients' => [
|
||||
'Ingrédients' => ['Viande de poulet (98%)', 'Sel', 'Epices'],
|
||||
],
|
||||
'portions' => [
|
||||
'lowPart' => 100,
|
||||
'highPart' => 150,
|
||||
'approximative' => false,
|
||||
],
|
||||
'allergens' => [
|
||||
['code' => 1, 'label' => 'Gluten'],
|
||||
],
|
||||
'brand' => [
|
||||
'code' => 'M01',
|
||||
'label' => 'Le Gaulois',
|
||||
],
|
||||
'is_seasonal' => false,
|
||||
'weight' => [
|
||||
'netWeight' => 1000,
|
||||
'grossWeight' => 1100,
|
||||
'theoreticalAverage' => 1050,
|
||||
],
|
||||
'nutriscore' => [
|
||||
'grade' => 'A',
|
||||
],
|
||||
'storage_condition' => [
|
||||
'instructions' => 'À conserver entre 0°C et 4°C',
|
||||
],
|
||||
'additives' => [
|
||||
['code' => 'E300', 'label' => 'Acide ascorbique'],
|
||||
],
|
||||
'compo_id' => (string) fake()->numberBetween(10000, 99999),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection(Config::string('database.arcadia_meta_model'));
|
||||
|
||||
$schema->dropIfExists('inco_sheets');
|
||||
|
||||
$schema->create('inco_sheets', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->string('label');
|
||||
$table->text('description');
|
||||
$table->json('allegations');
|
||||
$table->text('sell_arguments');
|
||||
$table->text('preparation_advices');
|
||||
$table->text('tips')->nullable();
|
||||
$table->string('sell_familly')->nullable();
|
||||
$table->json('ingredients');
|
||||
$table->json('portions')->nullable();
|
||||
$table->json('allergens');
|
||||
$table->json('brand');
|
||||
$table->boolean('is_seasonal')->default(false);
|
||||
$table->json('weight')->nullable();
|
||||
$table->json('nutriscore')->nullable();
|
||||
$table->json('storage_condition')->nullable();
|
||||
$table->json('additives');
|
||||
$table->string('compo_id')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('name');
|
||||
$table->index('compo_id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection(Config::string('database.arcadia_meta_model'))
|
||||
->dropIfExists('inco_sheets');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class () extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection(Config::string('database.arcadia_meta_model'));
|
||||
|
||||
$schema->dropIfExists('inco_compos');
|
||||
|
||||
$schema->create('inco_compos', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('id_inco');
|
||||
$table->json('identification');
|
||||
$table->json('energy');
|
||||
$table->json('reference_macronutrients');
|
||||
$table->json('portion_macronutrients');
|
||||
$table->json('fresh_produce_and_nuts');
|
||||
$table->json('reference_intakes');
|
||||
$table->json('nutri_score');
|
||||
$table->json('nutri_score_points');
|
||||
$table->json('minerals');
|
||||
$table->json('vitamins');
|
||||
$table->json('carbohydrates_detail');
|
||||
$table->json('fatty_acids');
|
||||
$table->json('amino_acids');
|
||||
$table->json('special_compounds');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('id_inco');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::connection(Config::string('database.arcadia_meta_model'))
|
||||
->dropIfExists('inco_compos');
|
||||
}
|
||||
};
|
||||
|
|
@ -4,18 +4,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
final class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call(EmployeeSeeder::class);
|
||||
$this->call([
|
||||
EmployeeSeeder::class,
|
||||
IncoSheetSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
57
database/seeders/IncoSheetSeeder.php
Normal file
57
database/seeders/IncoSheetSeeder.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Infra\Database\Models\IncoCompo;
|
||||
use Infra\Database\Models\IncoSheet;
|
||||
|
||||
final class IncoSheetSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Seed paired IncoSheet and IncoCompo entries.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$sheetDataList = [
|
||||
[
|
||||
'id' => '1',
|
||||
'compo_id' => '1',
|
||||
'name' => 'Poulet Rôti 1kg',
|
||||
'label' => 'Poulet Rôti aux Herbes',
|
||||
],
|
||||
[
|
||||
'id' => '2',
|
||||
'compo_id' => '2',
|
||||
'name' => 'Salade Niçoise 300g',
|
||||
'label' => 'Salade Niçoise',
|
||||
],
|
||||
[
|
||||
'id' => '3',
|
||||
'compo_id' => '3',
|
||||
'name' => 'Lasagnes Bolognaise 400g',
|
||||
'label' => 'Lasagnes Bolognaise',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($sheetDataList as $data) {
|
||||
if (! IncoSheet::query()->where('id', $data['id'])->exists()) {
|
||||
IncoSheet::factory()->create([
|
||||
'id' => $data['id'],
|
||||
'compo_id' => $data['compo_id'],
|
||||
'name' => $data['name'],
|
||||
'label' => $data['label'],
|
||||
]);
|
||||
}
|
||||
|
||||
if (! IncoCompo::query()->where('id', $data['compo_id'])->exists()) {
|
||||
IncoCompo::factory()->create([
|
||||
'id' => $data['compo_id'],
|
||||
'id_inco' => $data['compo_id'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
tests/Integration/Database/Seeders/DatabaseSeederTest.php
Normal file
29
tests/Integration/Database/Seeders/DatabaseSeederTest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration\Database\Seeders;
|
||||
|
||||
use Database\Seeders\DatabaseSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Infra\Database\Models\Employee;
|
||||
use Infra\Database\Models\IncoSheet;
|
||||
use Tests\TestCase;
|
||||
|
||||
covers(Employee::class, IncoSheet::class);
|
||||
|
||||
uses(TestCase::class, RefreshDatabase::class);
|
||||
|
||||
describe('DatabaseSeeder Integration Test', function (): void {
|
||||
it('runs all database seeders', function (): void {
|
||||
// GIVEN
|
||||
$seeder = new DatabaseSeeder();
|
||||
|
||||
// WHEN
|
||||
$seeder->run();
|
||||
|
||||
// THEN
|
||||
expect(Employee::count())->toBeGreaterThan(0)
|
||||
->and(IncoSheet::count())->toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
27
tests/Integration/Database/Seeders/EmployeeSeederTest.php
Normal file
27
tests/Integration/Database/Seeders/EmployeeSeederTest.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration\Database\Seeders;
|
||||
|
||||
use Database\Seeders\EmployeeSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Infra\Database\Models\Employee;
|
||||
use Tests\TestCase;
|
||||
|
||||
covers(Employee::class);
|
||||
|
||||
uses(TestCase::class, RefreshDatabase::class);
|
||||
|
||||
describe('EmployeeSeeder Integration Test', function (): void {
|
||||
it('seeds default employee records into the database', function (): void {
|
||||
// GIVEN
|
||||
$seeder = new EmployeeSeeder();
|
||||
|
||||
// WHEN
|
||||
$seeder->run();
|
||||
|
||||
// THEN
|
||||
expect(Employee::count())->toBe(4);
|
||||
});
|
||||
});
|
||||
29
tests/Integration/Database/Seeders/IncoSheetSeederTest.php
Normal file
29
tests/Integration/Database/Seeders/IncoSheetSeederTest.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration\Database\Seeders;
|
||||
|
||||
use Database\Seeders\IncoSheetSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Infra\Database\Models\IncoCompo;
|
||||
use Infra\Database\Models\IncoSheet;
|
||||
use Tests\TestCase;
|
||||
|
||||
covers(IncoSheet::class);
|
||||
|
||||
uses(TestCase::class, RefreshDatabase::class);
|
||||
|
||||
describe('IncoSheetSeeder Integration Test', function (): void {
|
||||
it('seeds paired IncoSheet and IncoCompo entries', function (): void {
|
||||
// GIVEN
|
||||
$seeder = new IncoSheetSeeder();
|
||||
|
||||
// WHEN
|
||||
$seeder->run();
|
||||
|
||||
// THEN
|
||||
expect(IncoSheet::count())->toBe(3)
|
||||
->and(IncoCompo::count())->toBe(3);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration\Infra\Database\Models;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Infra\Database\Models\Employee;
|
||||
use Tests\TestCase;
|
||||
|
||||
covers(Employee::class);
|
||||
|
||||
uses(TestCase::class, RefreshDatabase::class);
|
||||
|
||||
describe('Employee Eloquent Model & Factory', function (): void {
|
||||
it('creates and persists an Employee record via factory', function (): void {
|
||||
// GIVEN
|
||||
$employee = Employee::factory()->create();
|
||||
|
||||
// WHEN
|
||||
$retrieved = Employee::find($employee->id);
|
||||
|
||||
// THEN
|
||||
expect($retrieved)->not->toBeNull()
|
||||
->and($retrieved->id)->toBe($employee->id);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration\Infra\Database\Models;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Infra\Database\Models\IncoCompo;
|
||||
use Tests\TestCase;
|
||||
|
||||
covers(IncoCompo::class);
|
||||
|
||||
uses(TestCase::class, RefreshDatabase::class);
|
||||
|
||||
describe('IncoCompo Eloquent Model & Factory', function (): void {
|
||||
it('creates and persists an IncoCompo record via factory', function (): void {
|
||||
// GIVEN
|
||||
$compo = IncoCompo::factory()->create();
|
||||
|
||||
// WHEN
|
||||
$retrieved = IncoCompo::find($compo->id);
|
||||
|
||||
// THEN
|
||||
expect($retrieved)->not->toBeNull()
|
||||
->and($retrieved->id)->toBe($compo->id);
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Integration\Infra\Database\Models;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Infra\Database\Models\IncoSheet;
|
||||
use Tests\TestCase;
|
||||
|
||||
covers(IncoSheet::class);
|
||||
|
||||
uses(TestCase::class, RefreshDatabase::class);
|
||||
|
||||
describe('IncoSheet Eloquent Model & Factory', function (): void {
|
||||
it('creates and persists an IncoSheet record via factory', function (): void {
|
||||
// GIVEN
|
||||
$sheet = IncoSheet::factory()->create([
|
||||
'name' => 'Poulet Rôti 1kg Test',
|
||||
]);
|
||||
|
||||
// WHEN
|
||||
$retrieved = IncoSheet::find($sheet->id);
|
||||
|
||||
// THEN
|
||||
expect($retrieved)->not->toBeNull()
|
||||
->and($retrieved->id)->toBe($sheet->id)
|
||||
->and($retrieved->name)->toBe('Poulet Rôti 1kg Test');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue