Shows data and adds some tests for the OAuth check

This commit is contained in:
2026-02-16 12:24:50 +01:00
parent 9a10ff4727
commit e4259978de
2 changed files with 11 additions and 4 deletions

View File

@@ -34,7 +34,6 @@
}); });
// Dev auto-login route // Dev auto-login route
// if (app()->environment('local', 'testing')) {
Route::get('/login-for-testing', function () { Route::get('/login-for-testing', function () {
$user = \App\Models\User::where('email', 'jonathan@blijnder.nl')->first(); $user = \App\Models\User::where('email', 'jonathan@blijnder.nl')->first();
@@ -47,4 +46,3 @@
return redirect('/'); return redirect('/');
}); });
// }

View File

@@ -41,7 +41,16 @@ public function test_callback_matches_existing_user_by_email(): void
$socialiteUser = Mockery::mock(SocialiteUser::class); $socialiteUser = Mockery::mock(SocialiteUser::class);
$socialiteUser->shouldReceive('getEmail')->andReturn('existing@example.com'); $socialiteUser->shouldReceive('getEmail')->andReturn('existing@example.com');
$socialiteUser->shouldReceive('getName')->andReturn('Updated Name'); $socialiteUser->shouldReceive('getName')->andReturn('Updated Name');
$socialiteUser->shouldReceive('getId')->andReturn('azure-123');
$socialiteUser->shouldReceive('getAvatar')->andReturn(null);
$socialiteUser->shouldReceive('offsetExists')->andReturn(false); $socialiteUser->shouldReceive('offsetExists')->andReturn(false);
$socialiteUser->user = [
'jobTitle' => null,
'department' => null,
'companyName' => null,
'mobilePhone' => null,
'businessPhones' => [],
];
$driver = Mockery::mock(); $driver = Mockery::mock();
$driver->shouldReceive('user')->andReturn($socialiteUser); $driver->shouldReceive('user')->andReturn($socialiteUser);
@@ -57,7 +66,7 @@ public function test_callback_matches_existing_user_by_email(): void
$existingUser->refresh(); $existingUser->refresh();
$this->assertEquals('Original Name', $existingUser->name); $this->assertEquals('Updated Name', $existingUser->name);
$this->assertAuthenticatedAs($existingUser); $this->assertAuthenticatedAs($existingUser);
} }
@@ -78,7 +87,7 @@ public function test_login_jonathan_works_in_testing_env(): void
'name' => 'Jonathan', 'name' => 'Jonathan',
]); ]);
$this->get('/login-jonathan') $this->get('/login-for-testing')
->assertRedirect('/'); ->assertRedirect('/');
$user = User::where('email', 'jonathan@blijnder.nl')->first(); $user = User::where('email', 'jonathan@blijnder.nl')->first();