Skip to content

Commit

Permalink
fix(fixtures): persist each entity side
Browse files Browse the repository at this point in the history
see: #14
  • Loading branch information
n3wborn committed Sep 19, 2023
1 parent e53baf9 commit f6d6b26
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/DataFixtures/ProjectFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ public function __construct(
public function load(ObjectManager $manager): void
{
for ($i = 1; $i <= self::QUANTITY; ++$i) {
$count = rand(1, 5);
$project = $this->createProject($i);
$manager->persist($project);
$count = rand(1, 5);

for ($j = 1; $j <= $count; ++$j) {
$randCategory = $this->categoryRepository->findOneBy(['name' => 'category-'.rand(1, CategoryFixtures::CATEGORY_QUANTITY)]);
$randCategory->addProject($project);
$project->addCategory($randCategory);
$manager->persist($project);
$manager->persist($randCategory);
}
}
Expand Down

0 comments on commit f6d6b26

Please sign in to comment.