test sur création et retrait commentaire

This commit is contained in:
Julien Fastré 2021-05-13 17:31:46 +02:00
parent 3e85529468
commit f3eb418409

View File

@ -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)"); $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 * @dataProvider dataGenerateRandomRequestorValidData
*/ */