Fixed some deprecations related to kernel controller tests.

This commit is contained in:
Jan Böhmer 2019-11-23 15:03:08 +01:00
parent cd5f099965
commit 445b6b6a2b
2 changed files with 18 additions and 19 deletions

View file

@ -35,7 +35,6 @@ abstract class AbstractAdminControllerTest extends WebTestCase
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
self::bootKernel();
} }
public function readDataProvider() public function readDataProvider()
@ -55,6 +54,8 @@ abstract class AbstractAdminControllerTest extends WebTestCase
*/ */
public function testListEntries(string $user, bool $read) public function testListEntries(string $user, bool $read)
{ {
static::ensureKernelShutdown();
//Test read access //Test read access
$client = static::createClient([], [ $client = static::createClient([], [
'PHP_AUTH_USER' => $user, 'PHP_AUTH_USER' => $user,

View file

@ -32,10 +32,15 @@ class RedirectControllerTest extends WebTestCase
{ {
protected $em; protected $em;
protected $userRepo; protected $userRepo;
protected $client;
public function setUp() 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->em = self::$container->get(EntityManagerInterface::class);
$this->userRepo = $this->em->getRepository(User::class); $this->userRepo = $this->em->getRepository(User::class);
} }
@ -62,9 +67,9 @@ class RedirectControllerTest extends WebTestCase
*/ */
public function testUrlMatch($url, $expect_redirect) public function testUrlMatch($url, $expect_redirect)
{ {
$client = static::createClient(); //$client = static::createClient();
$client->request('GET', $url); $this->client->request('GET', $url);
$response = $client->getResponse(); $response = $this->client->getResponse();
if ($expect_redirect) { if ($expect_redirect) {
$this->assertEquals(302, $response->getStatusCode()); $this->assertEquals(302, $response->getStatusCode());
} }
@ -108,14 +113,11 @@ class RedirectControllerTest extends WebTestCase
$user->setLanguage($user_locale); $user->setLanguage($user_locale);
$this->em->flush(); $this->em->flush();
$client = static::createClient([], [
'PHP_AUTH_USER' => 'user',
'PHP_AUTH_PW' => 'test',
]);
$client->followRedirects(false);
$client->request('GET', $input_path); $this->client->followRedirects(false);
$this->assertEquals($redirect_path, $client->getResponse()->headers->get('Location')); $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); $user->setNeedPwChange(true);
$this->em->flush(); $this->em->flush();
$client = static::createClient([], [ $this->client->followRedirects(false);
'PHP_AUTH_USER' => 'user',
'PHP_AUTH_PW' => 'test',
]);
$client->followRedirects(false);
$client->request('GET', '/part/3'); $this->client->request('GET', '/part/3');
$this->assertEquals("/$locale/user/settings", $client->getResponse()->headers->get('Location')); $this->assertEquals("/$locale/user/settings", $this->client->getResponse()->headers->get('Location'));
} }
} }