From a351b0aada16b6b559a9ca750d495b7a379c06ae Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 24 Dec 2023 20:29:11 +0100 Subject: [PATCH 1/2] Fix canonicalize depreciation --- src/Wallabag/CoreBundle/Controller/ConfigController.php | 2 +- src/Wallabag/CoreBundle/Helper/ContentProxy.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 49d909e3d..fdf3b1dc0 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -668,7 +668,7 @@ class ConfigController extends AbstractController */ public function setLocaleAction(Request $request, ValidatorInterface $validator, $language = null) { - $errors = $validator->validate($language, (new LocaleConstraint())); + $errors = $validator->validate($language, (new LocaleConstraint(['canonicalize' => true]))); if (0 === \count($errors)) { $request->getSession()->set('_locale', $language); diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 52dcd8af0..b884b0d46 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -98,7 +98,7 @@ class ContentProxy $errors = $this->validator->validate( $value, - (new LocaleConstraint()) + (new LocaleConstraint(['canonicalize' => true])) ); if (0 === \count($errors)) { From babe87c33baaeb3605fca9e7244ab50d065acfb9 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Sun, 24 Dec 2023 20:37:54 +0100 Subject: [PATCH 2/2] Fix createClient() depreciation --- .../Controller/ConfigRestControllerTest.php | 2 +- .../ApiBundle/Controller/UserRestControllerTest.php | 10 +++++----- .../Controller/WallabagRestControllerTest.php | 6 +++--- tests/Wallabag/ApiBundle/WallabagApiTestCase.php | 12 +++++++++++- .../CoreBundle/Command/InstallCommandTest.php | 2 +- tests/Wallabag/CoreBundle/WallabagCoreTestCase.php | 2 +- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/tests/Wallabag/ApiBundle/Controller/ConfigRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/ConfigRestControllerTest.php index 65b2384d5..5547a92fb 100644 --- a/tests/Wallabag/ApiBundle/Controller/ConfigRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/ConfigRestControllerTest.php @@ -31,7 +31,7 @@ class ConfigRestControllerTest extends WallabagApiTestCase public function testGetConfigWithoutAuthentication() { - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); $client->request('GET', '/api/config.json'); $this->assertSame(401, $client->getResponse()->getStatusCode()); diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php index ad1e4974f..6419be390 100644 --- a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php @@ -30,7 +30,7 @@ class UserRestControllerTest extends WallabagApiTestCase public function testGetUserWithoutAuthentication() { - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); $client->request('GET', '/api/user.json'); $this->assertSame(401, $client->getResponse()->getStatusCode()); @@ -80,7 +80,7 @@ class UserRestControllerTest extends WallabagApiTestCase public function testCreateNewUserWithoutAuthentication() { // create a new client instead of using $this->client to be sure client isn't authenticated - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); $client->getContainer()->get(Config::class)->set('api_user_registration', 1); $client->request('PUT', '/api/user.json', [ 'username' => 'google', @@ -115,7 +115,7 @@ class UserRestControllerTest extends WallabagApiTestCase public function testCreateNewUserWithExistingEmail() { - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); $client->getContainer()->get(Config::class)->set('api_user_registration', 1); $client->request('PUT', '/api/user.json', [ 'username' => 'admin', @@ -144,7 +144,7 @@ class UserRestControllerTest extends WallabagApiTestCase public function testCreateNewUserWithTooShortPassword() { - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); $client->getContainer()->get(Config::class)->set('api_user_registration', 1); $client->request('PUT', '/api/user.json', [ 'username' => 'facebook', @@ -168,7 +168,7 @@ class UserRestControllerTest extends WallabagApiTestCase public function testCreateNewUserWhenRegistrationIsDisabled() { - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); $client->request('PUT', '/api/user.json', [ 'username' => 'facebook', 'password' => 'face', diff --git a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php index 98817bb13..9ccc8c4fe 100644 --- a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php @@ -10,7 +10,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase public function testGetVersion() { // create a new client instead of using $this->client to be sure client isn't authenticated - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); $client->request('GET', '/api/version'); $this->assertSame(200, $client->getResponse()->getStatusCode()); @@ -23,7 +23,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase public function testGetInfo() { // create a new client instead of using $this->client to be sure client isn't authenticated - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); $client->request('GET', '/api/info'); $this->assertSame(200, $client->getResponse()->getStatusCode()); @@ -40,7 +40,7 @@ class WallabagRestControllerTest extends WallabagApiTestCase public function testAllowedRegistration() { // create a new client instead of using $this->client to be sure client isn't authenticated - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); if (!$client->getContainer()->getParameter('fosuser_registration')) { $this->markTestSkipped('fosuser_registration is not enabled.'); diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php index 660fe1495..4cc2d0fc3 100644 --- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php +++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php @@ -31,12 +31,22 @@ abstract class WallabagApiTestCase extends WebTestCase $this->client = $this->createAuthorizedClient(); } + /** + * @return KernelBrowser + */ + protected function createUnauthorizedClient() + { + static::ensureKernelShutdown(); + + return static::createClient(); + } + /** * @return KernelBrowser */ protected function createAuthorizedClient() { - $client = static::createClient(); + $client = $this->createUnauthorizedClient(); $container = $client->getContainer(); /** @var UserManager $userManager */ diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php index 79487d6c1..83729d86b 100644 --- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php +++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php @@ -76,7 +76,7 @@ class InstallCommandTest extends WallabagCoreTestCase } else { // Create a new client to avoid the error: // Transaction commit failed because the transaction has been marked for rollback only. - $client = static::createClient(); + $client = $this->getNewClient(); $this->resetDatabase($client); } diff --git a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php index a6f34303e..3a9753154 100644 --- a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php +++ b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php @@ -71,7 +71,7 @@ abstract class WallabagCoreTestCase extends WebTestCase * [Doctrine\DBAL\ConnectionException] * Transaction commit failed because the transaction has been marked for rollback only. */ - $this->client = static::createClient(); + $this->client = $this->getNewClient(); } public function getEntityManager()