Comment::$toNumber type fixed. LoadCommentsData fixed according to new Comment constructor.

This commit is contained in:
Alexey Skobkin 2018-04-22 01:08:03 +03:00
parent 5d2ce0fe42
commit 31d49eb270
2 changed files with 24 additions and 20 deletions

View file

@ -11,7 +11,7 @@ use Skobkin\Bundle\PointToolsBundle\Entity\User;
class LoadCommentsData extends AbstractFixture implements OrderedFixtureInterface class LoadCommentsData extends AbstractFixture implements OrderedFixtureInterface
{ {
public function load(ObjectManager $om) public function load(ObjectManager $om): void
{ {
/** @var Post $post */ /** @var Post $post */
$post = $this->getReference('test_post_longpost'); $post = $this->getReference('test_post_longpost');
@ -25,29 +25,28 @@ class LoadCommentsData extends AbstractFixture implements OrderedFixtureInterfac
$this->getReference('test_user_99995'), $this->getReference('test_user_99995'),
]; ];
$comments = []; $text = 'Some text with [link to @skobkin-ru site](https://skobk.in/) and `code block`'.PHP_EOL.
'and some quotation:'.PHP_EOL.
'> test test quote'.PHP_EOL.
'and some text after';
foreach (range(1, 10000) as $num) { foreach (range(1, 10000) as $num) {
$comment = (new Comment()) $comment = new Comment(
->setNumber($num) $text,
->setDeleted(mt_rand(0, 15) ? false : true) new \DateTime(),
->setCreatedAt(new \DateTime()) false,
->setAuthor($users[array_rand($users)]) $post,
->setRec(false) $num,
->setText( ($num > 1 && !random_int(0, 4)) ? random_int(1, $num - 1) : null,
'Some text with [link to @skobkin-ru site](https://skobk.in/) and `code block`'.PHP_EOL. $users[array_rand($users)],
'and some quotation:'.PHP_EOL. []
'> test test quote'.PHP_EOL. );
'and some text after'
)
;
if (count($comments) > 0 && mt_rand(0, 1)) { if (!random_int(0, 15)) {
$comment->setParent($comments[mt_rand(0, count($comments) - 1)]); $comment->delete();
} }
$post->addComment($comment); $post->addComment($comment);
$comments[] = $comment;
$om->persist($comment); $om->persist($comment);
} }

View file

@ -67,7 +67,7 @@ class Comment
private $number; private $number;
/** /**
* @var int * @var int|null
* *
* @ORM\Column(name="to_number", type="integer") * @ORM\Column(name="to_number", type="integer")
*/ */
@ -99,7 +99,7 @@ class Comment
bool $rec, bool $rec,
Post $post, Post $post,
int $number, int $number,
int $toNumber, ?int $toNumber,
User $author, User $author,
array $files array $files
) { ) {
@ -154,6 +154,11 @@ class Comment
return $this->number; return $this->number;
} }
public function getToNumber(): ?int
{
return $this->toNumber;
}
public function getAuthor(): User public function getAuthor(): User
{ {
return $this->author; return $this->author;