From 2440c739e2566cc8b8dba0e10524b44f99e02e62 Mon Sep 17 00:00:00 2001 From: tykayn Date: Fri, 29 Nov 2019 10:19:12 +0100 Subject: [PATCH] :zap: format dates in fixtures --- .env | 3 ++- src/DataFixtures/AppPollFixtures.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.env b/.env index b914756..2e3809f 100644 --- a/.env +++ b/.env @@ -25,5 +25,6 @@ APP_SECRET=597b0529ac702d27dcb9089f7e69c362 # For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db" # For a PostgreSQL database, use: "postgresql://db_user:db_password@127.0.0.1:5432/db_name?serverVersion=11" # IMPORTANT: You MUST also configure your db driver and server_version in config/packages/doctrine.yaml -DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_name +DATABASE_URL=mysql://root:plopplop01@127.0.0.1:3306/tykayn + ###< doctrine/doctrine-bundle ### diff --git a/src/DataFixtures/AppPollFixtures.php b/src/DataFixtures/AppPollFixtures.php index 94e2875..09d859b 100644 --- a/src/DataFixtures/AppPollFixtures.php +++ b/src/DataFixtures/AppPollFixtures.php @@ -175,11 +175,11 @@ class AppPollFixtures extends Fixture { $poll = new Poll(); $choice = new Choice(); $firstDate = new DateTime(); - $choice->setName( $firstDate ); + $choice->setName( $firstDate->format( 'Y-m-d H:i:s' ) ); $choice2 = new Choice(); $choice3 = new Choice(); - $choice2->setName( $poll->addDaysToDate( $firstDate, 1 ) ); - $choice3->setName( $poll->addDaysToDate( $firstDate, 2 ) ); + $choice2->setName( $poll->addDaysToDate( $firstDate, 1 )->format( 'Y-m-d H:i:s' ) ); + $choice3->setName( $poll->addDaysToDate( $firstDate, 2 )->format( 'Y-m-d H:i:s' ) ); $poll->setTitle( "c'est pour aujourdhui ou pour demain" ) ->setDescription( 'Vous avez le choix dans la date' )