From b5dcc42ed2741640cc31dce074d20c4e7005596f Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Wed, 1 Jul 2020 10:52:55 +0800 Subject: [PATCH] Namespace the authentication in tests under 'backend.auth' Prevents conflicts with unit tests that might use another auth system, ie. Passport. Hat tip to @LukeTowers for pointing out my shame. --- tests/PluginTestCase.php | 2 +- tests/concerns/InteractsWithAuthentication.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/PluginTestCase.php b/tests/PluginTestCase.php index 728d5d430..1d4a66f00 100644 --- a/tests/PluginTestCase.php +++ b/tests/PluginTestCase.php @@ -28,7 +28,7 @@ abstract class PluginTestCase extends TestCase $app['cache']->setDefaultDriver('array'); $app->setLocale('en'); - $app->singleton('auth', function ($app) { + $app->singleton('backend.auth', function ($app) { $app['auth.loaded'] = true; return AuthManager::instance(); diff --git a/tests/concerns/InteractsWithAuthentication.php b/tests/concerns/InteractsWithAuthentication.php index a7950f230..5f5c3c8c7 100644 --- a/tests/concerns/InteractsWithAuthentication.php +++ b/tests/concerns/InteractsWithAuthentication.php @@ -29,7 +29,7 @@ trait InteractsWithAuthentication */ public function be(UserContract $user, $driver = null) { - $this->app['auth']->setUser($user); + $this->app['backend.auth']->setUser($user); } /** @@ -66,7 +66,7 @@ trait InteractsWithAuthentication */ protected function isAuthenticated($guard = null) { - return $this->app->make('auth')->guard($guard)->check(); + return $this->app->make('backend.auth')->guard($guard)->check(); } /** @@ -78,7 +78,7 @@ trait InteractsWithAuthentication */ public function assertAuthenticatedAs($user, $guard = null) { - $expected = $this->app->make('auth')->guard($guard)->user(); + $expected = $this->app->make('backend.auth')->guard($guard)->user(); $this->assertNotNull($expected, 'The current user is not authenticated.'); @@ -140,7 +140,7 @@ trait InteractsWithAuthentication */ protected function hasCredentials(array $credentials, $guard = null) { - $provider = $this->app->make('auth')->guard($guard)->getProvider(); + $provider = $this->app->make('backend.auth')->guard($guard)->getProvider(); $user = $provider->retrieveByCredentials($credentials);