Implement comments

This commit is contained in:
2024-06-10 20:51:42 +02:00
parent b4a1ae592f
commit 67ff9ff8db
20 changed files with 479 additions and 5 deletions

View File

@@ -125,4 +125,26 @@ class PostControllerTest extends WebTestCase
self::assertResponseRedirects('/');
self::assertSame(0, $this->repository->count());
}
public function testPostComment()
{
$fixture = new Post();
$fixture->setFoundDate(new \DateTimeImmutable('2024-01-01 00:00:00'));
$fixture->setCommentary('Cool stuff');
$this->manager->persist($fixture);
$this->manager->flush();
$this->client->request('GET', sprintf('%s%s', $this->path, $fixture->getId()));
self::assertResponseStatusCodeSame(200);
$this->client->submitForm('Comment', [
'comment[content]' => 'This is a comment',
]);
self::assertResponseRedirects(sprintf('%s%s', $this->path, $fixture->getId()));
$comments = $this->repository->find($fixture->getId())->getComments();
self::assertSame(1, $comments->count());
}
}