From f3eb41840989c064e3eae9de67d6dee88da3418c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 13 May 2021 17:31:46 +0200 Subject: [PATCH] =?UTF-8?q?test=20sur=20cr=C3=A9ation=20et=20retrait=20com?= =?UTF-8?q?mentaire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AccompanyingCourseApiControllerTest.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index bdeb5dba6..cdbbd0afc 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -87,6 +87,41 @@ class AccompanyingCourseApiControllerTest extends WebTestCase $this->assertEquals(404, $response->getStatusCode(), "Test that the response of rest api has a status code 'not found' (404)"); } + /** + * @dataProvider dataGenerateRandomRequestorValidData + */ + public function testCommentWithValidData(AccompanyingPeriod $period, $personId, $thirdPartyId) + { + $em = self::$container->get(EntityManagerInterface::class); + + $this->client->request( + Request::METHOD_POST, + sprintf('/api/1.0/person/accompanying-course/%d/comment.json', $period->getId()), + [], // parameters + [], // files + [], // server parameters + \json_encode([ 'type' => 'accompanying_period_comment', 'content' => "this is a text"]) + ); + $response = $this->client->getResponse(); + $data = \json_decode($response->getContent(), true); + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertArrayHasKey('id', $data); + + $this->client->request( + Request::METHOD_DELETE, + sprintf('/api/1.0/person/accompanying-course/%d/comment.json', $period->getId()), + [], // parameters + [], // files + [], // server parameters + \json_encode([ 'type' => 'accompanying_period_comment', 'id' => $data['id']]) + ); + $response = $this->client->getResponse(); + $data = \json_decode($response->getContent(), true); + + $this->assertEquals(200, $response->getStatusCode()); + } + /** * @dataProvider dataGenerateRandomRequestorValidData */