Skip to content

Commit 5589af6

Browse files
committed
Added another test
1 parent 7ceecac commit 5589af6

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tests/Emulator/EmulatedAuthenticationTest.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function test_database_sync_fails_without_object_guid()
9696
$this->assertFalse(Auth::attempt(['mail' => $user->mail[0], 'password' => 'secret']));
9797
}
9898

99-
public function test_database_authentication_falls_back_when_enabled()
99+
public function test_database_authentication_fallback_works_when_enabled_and_exception_is_thrown()
100100
{
101101
$this->doesntExpectEvents([
102102
Authenticating::class,
@@ -131,6 +131,41 @@ public function test_database_authentication_falls_back_when_enabled()
131131
$this->assertTrue($guard->attempt(['email' => $user->email, 'password' => 'secret']));
132132
}
133133

134+
public function test_database_authentication_fallback_works_when_enabled_and_null_is_returned()
135+
{
136+
$this->doesntExpectEvents([
137+
Authenticating::class,
138+
Authenticated::class,
139+
DiscoveredWithCredentials::class,
140+
Importing::class,
141+
Imported::class,
142+
Synchronizing::class,
143+
Synchronized::class,
144+
]);
145+
146+
DirectoryEmulator::setup();
147+
148+
$this->setupDatabaseUserProvider([
149+
'database' => ['fallback' => true],
150+
]);
151+
152+
$guard = Auth::guard();
153+
154+
$databaseUserProvider = $guard->getProvider();
155+
156+
$databaseUserProvider->resolveUsersUsing(function () {
157+
return;
158+
});
159+
160+
$user = TestUserModelStub::create([
161+
'name' => 'John Doe',
162+
'email' => '[email protected]',
163+
'password' => Hash::make('secret'),
164+
]);
165+
166+
$this->assertTrue($guard->attempt(['email' => $user->email, 'password' => 'secret']));
167+
}
168+
134169
public function test_plain_ldap_authentication_passes()
135170
{
136171
$this->expectsEvents([

0 commit comments

Comments
 (0)