Fix direct kernel deprecation in AccompanyingCourseApiControllerTest

This commit is contained in:
Julien Fastré 2023-10-16 13:13:24 +02:00
parent b65f76262a
commit efcb903d10
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -52,16 +52,6 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
private ?int $personId = null;
private KernelBrowser $client;
/**
* Setup before each test method (see phpunit doc).
*/
protected function setUp(): void
{
$this->client = $this->getClientAuthenticated();
}
protected function tearDown(): void
{
self::ensureKernelShutdown();
@ -427,8 +417,9 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testAccompanyingCourseShow(int $personId, int $periodId)
{
$c = $this->client->request(Request::METHOD_GET, sprintf('/api/1.0/person/accompanying-course/%d.json', $periodId));
$response = $this->client->getResponse();
$client = $this->getClientAuthenticated();
$client->request(Request::METHOD_GET, sprintf('/api/1.0/person/accompanying-course/%d.json', $periodId));
$response = $client->getResponse();
$this->assertTrue(in_array($response->getStatusCode(), [200, 422], true));
@ -548,12 +539,13 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
*/
public function testReferralAvailable(int $personId, int $periodId)
{
$this->client->request(
$client = $this->getClientAuthenticated();
$client->request(
Request::METHOD_POST,
sprintf('/api/1.0/person/accompanying-course/%d/referrers-suggested.json', $periodId)
);
$this->assertTrue(in_array($this->client->getResponse()->getStatusCode(), [200, 422], true));
$this->assertTrue(in_array($client->getResponse()->getStatusCode(), [200, 422], true));
}
/**
@ -732,8 +724,9 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase
public function testShow404()
{
$this->client->request(Request::METHOD_GET, sprintf('/api/1.0/person/accompanying-course/%d.json', 99999));
$response = $this->client->getResponse();
$client = $this->getClientAuthenticated();
$client->request(Request::METHOD_GET, sprintf('/api/1.0/person/accompanying-course/%d.json', 99999));
$response = $client->getResponse();
$this->assertEquals(404, $response->getStatusCode(), "Test that the response of rest api has a status code 'not found' (404)");
}