From 445b6b6a2b529c4f6d99432f683ec75a14546cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sat, 23 Nov 2019 15:03:08 +0100 Subject: [PATCH] Fixed some deprecations related to kernel controller tests. --- .../AbstractAdminControllerTest.php | 3 +- tests/Controller/RedirectControllerTest.php | 34 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/tests/Controller/AdminPages/AbstractAdminControllerTest.php b/tests/Controller/AdminPages/AbstractAdminControllerTest.php index 0f19f804..789d897f 100644 --- a/tests/Controller/AdminPages/AbstractAdminControllerTest.php +++ b/tests/Controller/AdminPages/AbstractAdminControllerTest.php @@ -35,7 +35,6 @@ abstract class AbstractAdminControllerTest extends WebTestCase public function setUp() { parent::setUp(); - self::bootKernel(); } public function readDataProvider() @@ -55,6 +54,8 @@ abstract class AbstractAdminControllerTest extends WebTestCase */ public function testListEntries(string $user, bool $read) { + static::ensureKernelShutdown(); + //Test read access $client = static::createClient([], [ 'PHP_AUTH_USER' => $user, diff --git a/tests/Controller/RedirectControllerTest.php b/tests/Controller/RedirectControllerTest.php index f5a324a4..d49e3963 100644 --- a/tests/Controller/RedirectControllerTest.php +++ b/tests/Controller/RedirectControllerTest.php @@ -32,10 +32,15 @@ class RedirectControllerTest extends WebTestCase { protected $em; protected $userRepo; + protected $client; public function setUp() { - self::bootKernel(); + $this->client = static::createClient([], [ + 'PHP_AUTH_USER' => 'user', + 'PHP_AUTH_PW' => 'test', + ]); + $this->client->disableReboot(); $this->em = self::$container->get(EntityManagerInterface::class); $this->userRepo = $this->em->getRepository(User::class); } @@ -62,9 +67,9 @@ class RedirectControllerTest extends WebTestCase */ public function testUrlMatch($url, $expect_redirect) { - $client = static::createClient(); - $client->request('GET', $url); - $response = $client->getResponse(); + //$client = static::createClient(); + $this->client->request('GET', $url); + $response = $this->client->getResponse(); if ($expect_redirect) { $this->assertEquals(302, $response->getStatusCode()); } @@ -108,14 +113,11 @@ class RedirectControllerTest extends WebTestCase $user->setLanguage($user_locale); $this->em->flush(); - $client = static::createClient([], [ - 'PHP_AUTH_USER' => 'user', - 'PHP_AUTH_PW' => 'test', - ]); - $client->followRedirects(false); - $client->request('GET', $input_path); - $this->assertEquals($redirect_path, $client->getResponse()->headers->get('Location')); + + $this->client->followRedirects(false); + $this->client->request('GET', $input_path); + $this->assertEquals($redirect_path, $this->client->getResponse()->headers->get('Location')); } /** @@ -136,13 +138,9 @@ class RedirectControllerTest extends WebTestCase $user->setNeedPwChange(true); $this->em->flush(); - $client = static::createClient([], [ - 'PHP_AUTH_USER' => 'user', - 'PHP_AUTH_PW' => 'test', - ]); - $client->followRedirects(false); + $this->client->followRedirects(false); - $client->request('GET', '/part/3'); - $this->assertEquals("/$locale/user/settings", $client->getResponse()->headers->get('Location')); + $this->client->request('GET', '/part/3'); + $this->assertEquals("/$locale/user/settings", $this->client->getResponse()->headers->get('Location')); } }