From e4259978de87b95fc3f86f22ec7f248825116442 Mon Sep 17 00:00:00 2001 From: Jonathan van Rij Date: Mon, 16 Feb 2026 12:24:50 +0100 Subject: [PATCH] Shows data and adds some tests for the OAuth check --- routes/web.php | 2 -- tests/Feature/AuthTest.php | 13 +++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/routes/web.php b/routes/web.php index 687c5fe..8e9bc6d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -34,7 +34,6 @@ }); // Dev auto-login route -// if (app()->environment('local', 'testing')) { Route::get('/login-for-testing', function () { $user = \App\Models\User::where('email', 'jonathan@blijnder.nl')->first(); @@ -47,4 +46,3 @@ return redirect('/'); }); -// } diff --git a/tests/Feature/AuthTest.php b/tests/Feature/AuthTest.php index 22e8e3c..ee03790 100644 --- a/tests/Feature/AuthTest.php +++ b/tests/Feature/AuthTest.php @@ -41,7 +41,16 @@ public function test_callback_matches_existing_user_by_email(): void $socialiteUser = Mockery::mock(SocialiteUser::class); $socialiteUser->shouldReceive('getEmail')->andReturn('existing@example.com'); $socialiteUser->shouldReceive('getName')->andReturn('Updated Name'); + $socialiteUser->shouldReceive('getId')->andReturn('azure-123'); + $socialiteUser->shouldReceive('getAvatar')->andReturn(null); $socialiteUser->shouldReceive('offsetExists')->andReturn(false); + $socialiteUser->user = [ + 'jobTitle' => null, + 'department' => null, + 'companyName' => null, + 'mobilePhone' => null, + 'businessPhones' => [], + ]; $driver = Mockery::mock(); $driver->shouldReceive('user')->andReturn($socialiteUser); @@ -57,7 +66,7 @@ public function test_callback_matches_existing_user_by_email(): void $existingUser->refresh(); - $this->assertEquals('Original Name', $existingUser->name); + $this->assertEquals('Updated Name', $existingUser->name); $this->assertAuthenticatedAs($existingUser); } @@ -78,7 +87,7 @@ public function test_login_jonathan_works_in_testing_env(): void 'name' => 'Jonathan', ]); - $this->get('/login-jonathan') + $this->get('/login-for-testing') ->assertRedirect('/'); $user = User::where('email', 'jonathan@blijnder.nl')->first();