mirror of
https://github.com/MarijnDoeve/TijdVoorDeTest.git
synced 2026-03-06 04:44:19 +01:00
34 lines
849 B
PHP
34 lines
849 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tvdt\DataFixtures;
|
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
|
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
|
|
use Doctrine\Persistence\ObjectManager;
|
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
|
use Tvdt\Entity\User;
|
|
|
|
final class TestFixtures extends Fixture implements FixtureGroupInterface
|
|
{
|
|
public function __construct(
|
|
private UserPasswordHasherInterface $passwordHasher,
|
|
) {}
|
|
|
|
public static function getGroups(): array
|
|
{
|
|
return ['test'];
|
|
}
|
|
|
|
public function load(ObjectManager $manager): void
|
|
{
|
|
$user = new User();
|
|
$user->email = 'test@example.org';
|
|
$user->password = $this->passwordHasher->hashPassword($user, 'test1234');
|
|
|
|
$manager->persist($user);
|
|
$manager->flush();
|
|
}
|
|
}
|