From 622b0719ee203b47518e5d8905acbd53a9c5c501 Mon Sep 17 00:00:00 2001 From: Julian PEREZ-RAMIREZ <julian.perez-ramirez@imt-atlantique.net> Date: Tue, 25 Feb 2025 21:02:44 +0100 Subject: [PATCH] adding dependency to manage db seed to create sample data to test --- web_app/composer.json | 1 + web_app/config/bundles.php | 1 + web_app/src/DataFixtures/AppFixtures.php | 17 +++++++++++++++++ web_app/symfony.lock | 12 ++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 web_app/src/DataFixtures/AppFixtures.php diff --git a/web_app/composer.json b/web_app/composer.json index 61bf1a0..8c26bcb 100644 --- a/web_app/composer.json +++ b/web_app/composer.json @@ -69,6 +69,7 @@ } }, "require-dev": { + "doctrine/doctrine-fixtures-bundle": "^4.0", "symfony/maker-bundle": "^1.62" } } diff --git a/web_app/config/bundles.php b/web_app/config/bundles.php index de8898b..fd50f83 100644 --- a/web_app/config/bundles.php +++ b/web_app/config/bundles.php @@ -5,4 +5,5 @@ return [ Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], + Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], ]; diff --git a/web_app/src/DataFixtures/AppFixtures.php b/web_app/src/DataFixtures/AppFixtures.php new file mode 100644 index 0000000..987f6fe --- /dev/null +++ b/web_app/src/DataFixtures/AppFixtures.php @@ -0,0 +1,17 @@ +<?php + +namespace App\DataFixtures; + +use Doctrine\Bundle\FixturesBundle\Fixture; +use Doctrine\Persistence\ObjectManager; + +class AppFixtures extends Fixture +{ + public function load(ObjectManager $manager): void + { + // $product = new Product(); + // $manager->persist($product); + + $manager->flush(); + } +} diff --git a/web_app/symfony.lock b/web_app/symfony.lock index b7d0228..2886e0a 100644 --- a/web_app/symfony.lock +++ b/web_app/symfony.lock @@ -13,6 +13,18 @@ "src/Repository/.gitignore" ] }, + "doctrine/doctrine-fixtures-bundle": { + "version": "4.0", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "3.0", + "ref": "1f5514cfa15b947298df4d771e694e578d4c204d" + }, + "files": [ + "src/DataFixtures/AppFixtures.php" + ] + }, "doctrine/doctrine-migrations-bundle": { "version": "3.4", "recipe": { -- GitLab