feat(db): add entities
This commit is contained in:
34
tests/Common/Generators/CommentGeneratorTrait.php
Normal file
34
tests/Common/Generators/CommentGeneratorTrait.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Common\Generators;
|
||||
|
||||
use App\Entity\Database\Comments\Comment;
|
||||
use App\Entity\Database\Posts\Post;
|
||||
use App\Tests\Common\DatabaseTestTrait;
|
||||
use App\Tests\Common\FakerTrait;
|
||||
|
||||
trait CommentGeneratorTrait
|
||||
{
|
||||
use FakerTrait;
|
||||
use DatabaseTestTrait;
|
||||
|
||||
private function createComment(int $id, Post $post): Comment
|
||||
{
|
||||
$comment = new Comment(
|
||||
$id,
|
||||
$post,
|
||||
$this->getFaker()->name(),
|
||||
$this->getFaker()->email(),
|
||||
$this->getFaker()->text(500)
|
||||
);
|
||||
|
||||
$this->getEntityManager()->persist($comment);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$this->getEntityManager()->refresh($post);
|
||||
|
||||
return $comment;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user