+ public function test_social_registration_with_no_name_uses_email_as_name()
+ {
+
+ $this->setSettings(['registration-enabled' => 'true']);
+ config(['GITHUB_APP_ID' => 'abc123', 'GITHUB_APP_SECRET' => '123abc', 'APP_URL' => 'http://localhost']);
+
+ $mockSocialite = Mockery::mock(Factory::class);
+ $this->app[Factory::class] = $mockSocialite;
+ $mockSocialDriver = Mockery::mock(Provider::class);
+ $mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
+
+ $mockSocialite->shouldReceive('driver')->twice()->with('github')->andReturn($mockSocialDriver);
+ $mockSocialDriver->shouldReceive('redirect')->once()->andReturn(redirect('/'));
+ $mockSocialDriver->shouldReceive('user')->once()->andReturn($mockSocialUser);
+
+ $mockSocialUser->shouldReceive('getId')->twice()->andReturn(1);
+ $mockSocialUser->shouldReceive('getEmail')->twice()->andReturn($user->email);
+ $mockSocialUser->shouldReceive('getName')->once()->andReturn('');
+ $mockSocialUser->shouldReceive('getAvatar')->once()->andReturn('avatar_placeholder');
+
+ $this->get('/register/service/github');
+ $this->get('/login/service/github/callback');
+ $this->assertDatabaseHas('users', ['name' => 'nonameuser', 'email' => $user->email]);
+ $user = $user->whereEmail($user->email)->first();
+ $this->assertDatabaseHas('social_accounts', ['user_id' => $user->id]);
+ }
+