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();