feat(db): add entities
This commit is contained in:
37
tests/Common/Generators/PostGeneratorTrait.php
Normal file
37
tests/Common/Generators/PostGeneratorTrait.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Common\Generators;
|
||||
|
||||
use App\Entity\Database\Posts\Post;
|
||||
use App\Tests\Common\DatabaseTestTrait;
|
||||
use App\Tests\Common\FakerTrait;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
trait PostGeneratorTrait
|
||||
{
|
||||
use UserGeneratorTrait;
|
||||
use FakerTrait;
|
||||
use DatabaseTestTrait;
|
||||
|
||||
private const int POST_GENERATOR_SYSTEM_POST_USER = 1000;
|
||||
|
||||
private function createPost(int $id): Post
|
||||
{
|
||||
$user = $this->createUser($id + self::POST_GENERATOR_SYSTEM_POST_USER);
|
||||
|
||||
$post = new Post(
|
||||
$id,
|
||||
$user,
|
||||
$this->getFaker()->text(500),
|
||||
$this->getFaker()->text(5000),
|
||||
new ArrayCollection(),
|
||||
);
|
||||
|
||||
$this->getEntityManager()->persist($post);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
return $post;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user