35 lines
758 B
PHP
35 lines
758 B
PHP
|
<?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;
|
||
|
}
|
||
|
}
|