From 6f3d71b84d6ba5b293daa82158bf54cb48b5fcf6 Mon Sep 17 00:00:00 2001 From: ByteHunter Date: Thu, 20 Mar 2025 16:33:19 +0000 Subject: [PATCH 1/4] Mark strings for translations --- src/Authenticator/AuthenticationRequiredException.php | 2 +- src/Authenticator/UnauthenticatedException.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Authenticator/AuthenticationRequiredException.php b/src/Authenticator/AuthenticationRequiredException.php index 910fdec7..8de1db10 100644 --- a/src/Authenticator/AuthenticationRequiredException.php +++ b/src/Authenticator/AuthenticationRequiredException.php @@ -45,7 +45,7 @@ class AuthenticationRequiredException extends HttpException */ public function __construct(array $headers, string $body = '', int $code = 401) { - parent::__construct('Authentication is required to continue', $code); + parent::__construct(__d('authentication', 'Authentication is required to continue'), $code); $this->headers = $headers; $this->body = $body; } diff --git a/src/Authenticator/UnauthenticatedException.php b/src/Authenticator/UnauthenticatedException.php index 7546ac42..8f5a4823 100644 --- a/src/Authenticator/UnauthenticatedException.php +++ b/src/Authenticator/UnauthenticatedException.php @@ -38,7 +38,7 @@ class UnauthenticatedException extends HttpException public function __construct(string $message = '', int $code = 401, ?Throwable $previous = null) { if (!$message) { - $message = 'Authentication is required to continue'; + $message = __d('authentication', 'Authentication is required to continue'); } parent::__construct($message, $code, $previous); } From bd085951dec936c3012b330cbafae080063c5284 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Thu, 20 Mar 2025 17:59:46 +0100 Subject: [PATCH 2/4] add missing use statements --- src/Authenticator/AuthenticationRequiredException.php | 1 + src/Authenticator/UnauthenticatedException.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Authenticator/AuthenticationRequiredException.php b/src/Authenticator/AuthenticationRequiredException.php index 8de1db10..1bdd6370 100644 --- a/src/Authenticator/AuthenticationRequiredException.php +++ b/src/Authenticator/AuthenticationRequiredException.php @@ -17,6 +17,7 @@ namespace Authentication\Authenticator; use Cake\Http\Exception\HttpException; +use function Cake\I18n\__d; /** * An exception for stateless authenticators when credentials are wrong/missing. diff --git a/src/Authenticator/UnauthenticatedException.php b/src/Authenticator/UnauthenticatedException.php index 8f5a4823..538129d8 100644 --- a/src/Authenticator/UnauthenticatedException.php +++ b/src/Authenticator/UnauthenticatedException.php @@ -18,6 +18,7 @@ use Cake\Http\Exception\HttpException; use Throwable; +use function Cake\I18n\__d; /** * An exception that signals that authentication was required but missing. From 434cf9961ffd53ec26c26a666308f2dca41a3117 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Thu, 20 Mar 2025 18:03:52 +0100 Subject: [PATCH 3/4] add missing cache config for testsuite --- tests/bootstrap.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 1232baba..bc8a4f4e 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -15,6 +15,7 @@ */ use Authentication\Plugin as AuthenticationPlugin; +use Cake\Cache\Cache; use Cake\Core\Configure; use Cake\Core\Plugin; use Cake\Datasource\ConnectionManager; @@ -54,6 +55,14 @@ ], ]); +Cache::setConfig([ + '_cake_translations_' => [ + 'engine' => 'File', + 'prefix' => 'cake_core_', + 'serialize' => true, + ], +]); + if (!getenv('DB_URL')) { putenv('DB_URL=sqlite:///:memory:'); } From bd9658f6def8a263463cacdbd9e6ac1a8801e50f Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Thu, 20 Mar 2025 18:29:47 +0100 Subject: [PATCH 4/4] Update tests/bootstrap.php Co-authored-by: Mark Story --- tests/bootstrap.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bc8a4f4e..b55f16b5 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -57,9 +57,7 @@ Cache::setConfig([ '_cake_translations_' => [ - 'engine' => 'File', - 'prefix' => 'cake_core_', - 'serialize' => true, + 'engine' => 'Array', ], ]);