diff --git a/src/Authenticator/AuthenticationRequiredException.php b/src/Authenticator/AuthenticationRequiredException.php index 910fdec7..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. @@ -45,7 +46,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..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. @@ -38,7 +39,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); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 1232baba..b55f16b5 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,12 @@ ], ]); +Cache::setConfig([ + '_cake_translations_' => [ + 'engine' => 'Array', + ], +]); + if (!getenv('DB_URL')) { putenv('DB_URL=sqlite:///:memory:'); }