mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Optimiced DummyFictures
This commit is contained in:
parent
77122f481e
commit
2c169a038f
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user