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.
This commit is contained in:
Ben Thomson 2020-07-01 10:52:55 +08:00
parent 9412a2bb20
commit b5dcc42ed2
No known key found for this signature in database
GPG Key ID: 8BDB18DD0909BE22
2 changed files with 5 additions and 5 deletions

View File

@ -28,7 +28,7 @@ abstract class PluginTestCase extends TestCase
$app['cache']->setDefaultDriver('array'); $app['cache']->setDefaultDriver('array');
$app->setLocale('en'); $app->setLocale('en');
$app->singleton('auth', function ($app) { $app->singleton('backend.auth', function ($app) {
$app['auth.loaded'] = true; $app['auth.loaded'] = true;
return AuthManager::instance(); return AuthManager::instance();

View File

@ -29,7 +29,7 @@ trait InteractsWithAuthentication
*/ */
public function be(UserContract $user, $driver = null) 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) 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) 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.'); $this->assertNotNull($expected, 'The current user is not authenticated.');
@ -140,7 +140,7 @@ trait InteractsWithAuthentication
*/ */
protected function hasCredentials(array $credentials, $guard = null) 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); $user = $provider->retrieveByCredentials($credentials);