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 */