From 68db9c66479a9decb341bf4548f29ee1eb361748 Mon Sep 17 00:00:00 2001 From: Alexis Lefebvre Date: Wed, 3 Jul 2024 12:04:19 +0200 Subject: [PATCH] chore: persist and flush fixtures only once, and remove call to clone --- tests/App/DataFixtures/ORM/LoadUserData.php | 1 - .../DataFixtures/MongoDB/LoadUserDataFixture.php | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/App/DataFixtures/ORM/LoadUserData.php b/tests/App/DataFixtures/ORM/LoadUserData.php index c440d5ed..2670829f 100644 --- a/tests/App/DataFixtures/ORM/LoadUserData.php +++ b/tests/App/DataFixtures/ORM/LoadUserData.php @@ -27,7 +27,6 @@ public function load(ObjectManager $manager): void $user->setEmail('foo@bar.com'); $manager->persist($user); - $manager->flush(); $this->addReference('user', $user); diff --git a/tests/AppConfigMongodb/DataFixtures/MongoDB/LoadUserDataFixture.php b/tests/AppConfigMongodb/DataFixtures/MongoDB/LoadUserDataFixture.php index f18f2d2d..a16dd1e1 100755 --- a/tests/AppConfigMongodb/DataFixtures/MongoDB/LoadUserDataFixture.php +++ b/tests/AppConfigMongodb/DataFixtures/MongoDB/LoadUserDataFixture.php @@ -32,13 +32,14 @@ public function load(ObjectManager $manager): void $user->setEmail('foo@bar.com'); $manager->persist($user); - $manager->flush(); $this->addReference('user', $user); - $user = clone $this->getReference('user'); + $user2 = new User(); + $user2->setName('alice bar'); + $user2->setEmail('alice@bar.com'); - $manager->persist($user); + $manager->persist($user2); $manager->flush(); } }