Skip to content

Commit

Permalink
feat(user): add UserFixtures
Browse files Browse the repository at this point in the history
see: #20, #30
  • Loading branch information
n3wborn committed Jan 13, 2024
1 parent 6b511b4 commit 31e2205
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/DataFixtures/UserFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,20 @@ public function __construct(

public function load(ObjectManager $manager): void
{
$admin = $this->createAdmin();
$manager->persist($admin);
$count = rand(1, 5);

for ($i = 1; $i <= self::QUANTITY; ++$i) {
$user = $this->createUser($i);
$manager->persist($user);

for ($j = 1; $j <= $count; ++$j) {
$randProject = $this->projectRepository->findOneByName('project-'.rand(1, ProjectFixtures::QUANTITY));
$user->addProject($randProject);
$manager->persist($user);
}
}

$manager->persist($this->createAdmin());

$manager->flush();
}

Expand Down

0 comments on commit 31e2205

Please sign in to comment.