Implement comments (#10)
Allow logged users to comment posts. Edition is not allowed via the API since it doesn't support auth yet. Symfony UX is used with Turbo to avoid full pages reload, without JavaScript™. Co-authored-by: clfreville2 <clement.freville2@etu.uca.fr> Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/herbarium/pulls/10
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user