diff --git a/application/src/DataFixtures/DummyFixtures.php b/application/src/DataFixtures/DummyFixtures.php index 8ff377a..2026344 100644 --- a/application/src/DataFixtures/DummyFixtures.php +++ b/application/src/DataFixtures/DummyFixtures.php @@ -5,6 +5,8 @@ namespace App\DataFixtures; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\Persistence\ObjectManager; use App\Entity\User; +use FOS\UserBundle\Util\PasswordUpdater; +use FOS\UserBundle\Doctrine\UserManager; /** * Never execute this fixture on a livesystem! @@ -15,11 +17,23 @@ class DummyFixtures extends Fixture { public function load(ObjectManager $manager) { + $this->addTestUser(); + $manager->flush(); } - - public function adminUser() - { - $admin = new User(); - $source = $admin->getSource(); + + protected function addTestUser():void{ + /** + * @var UserManager $userManager + */ + $userManager = $this->container->get('fos_user.user_manager'); + /** + * @var User $testUser + */ + $testUser = $userManager->createUser(); + $testUser->setEmail("test@test.de"); + $testUser->setUsername("test"); + $testUser->setPlainPassword('test'); + $testUser->setEnabled(true); + $userManager->updateUser($testUser); } }