From efcb903d10ee0335a4c76fb4fa6d1e3a940ee83a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 16 Oct 2023 13:13:24 +0200 Subject: [PATCH] Fix direct kernel deprecation in AccompanyingCourseApiControllerTest --- .../AccompanyingCourseApiControllerTest.php | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 64b78f49e..4f2d19f54 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -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)"); }