Skip to content

Commit

Permalink
feat(category): add fixtures wip
Browse files Browse the repository at this point in the history
  • Loading branch information
n3wborn committed Sep 13, 2023
1 parent 6425a93 commit 69029ca
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/DataFixtures/CategoryFixtures.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\DataFixtures;

use App\Entity\Category;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;

final class CategoryFixtures extends Fixture
{
public const CATEGORY_QUANTITY = 20;

public function load(ObjectManager $manager): void
{
for ($i = 1; $i <= self::CATEGORY_QUANTITY; ++$i) {
$category = $this->createCategory($i);
$manager->persist($category);
}

$manager->flush();
}

private function createCategory(int $number): Category
{
return (new Category())
->setName("category-$number");
}
}

0 comments on commit 69029ca

Please sign in to comment.