Optimiced DummyFictures

This commit is contained in:
Kevin Frantz 2018-11-23 19:10:24 +01:00
parent 77122f481e
commit 2c169a038f

View File

@ -5,6 +5,8 @@ namespace App\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager; use Doctrine\Common\Persistence\ObjectManager;
use App\Entity\User; use App\Entity\User;
use FOS\UserBundle\Util\PasswordUpdater;
use FOS\UserBundle\Doctrine\UserManager;
/** /**
* Never execute this fixture on a livesystem! * Never execute this fixture on a livesystem!
@ -15,11 +17,23 @@ class DummyFixtures extends Fixture
{ {
public function load(ObjectManager $manager) public function load(ObjectManager $manager)
{ {
$this->addTestUser();
$manager->flush();
} }
public function adminUser() protected function addTestUser():void{
{ /**
$admin = new User(); * @var UserManager $userManager
$source = $admin->getSource(); */
$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);
} }
} }