diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f2e6fe7185..5986c258c6 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -22893,12 +22893,6 @@ parameters: count: 1 path: tests/Feature/LdapIntegration.php - - - rawMessage: 'Call to an undefined method Mockery\Expectation::shouldReceive().' - identifier: method.notFound - count: 2 - path: tests/Feature/LoginAndRegistration.php - - rawMessage: ''' Call to deprecated method forceRootUrl() of class Illuminate\Routing\UrlGenerator: @@ -22908,12 +22902,6 @@ parameters: count: 1 path: tests/Feature/LoginAndRegistration.php - - - rawMessage: 'Call to method shouldReceive() on an unknown class Laravel\Socialite\PingIdentity\Provider.' - identifier: class.notFound - count: 2 - path: tests/Feature/LoginAndRegistration.php - - rawMessage: 'Cannot call method delete() on App\Models\User|null.' identifier: method.nonObject diff --git a/tests/Feature/LoginAndRegistration.php b/tests/Feature/LoginAndRegistration.php index acb5dfc19e..fef953801d 100644 --- a/tests/Feature/LoginAndRegistration.php +++ b/tests/Feature/LoginAndRegistration.php @@ -11,6 +11,7 @@ use Illuminate\Support\Facades\URL; use Illuminate\Support\Str; use Laravel\Socialite\Facades\Socialite; +use Laravel\Socialite\Two\User as SocialiteUser; use LogicException; use Mockery; use PHPUnit\Framework\Attributes\DataProvider; @@ -364,23 +365,13 @@ public function testCustomOauthDisplayNames(string $serviceName): void */ public function testPingIdentityProvider(): void { - // Stolen from: https://laracasts.com/discuss/channels/testing/testing-laravel-socialite-callback - $abstractUser = Mockery::mock('Laravel\Socialite\Two\User'); - $abstractUser->shouldReceive('getId') - ->andReturn(1234567890) - ->shouldReceive('getEmail') - ->andReturn('cdash@test.com') - ->shouldReceive('getNickname') - ->andReturn('Pseudo') - ->shouldReceive('getName') - ->andReturn('Arlette Laguiller') - ->shouldReceive('getAvatar') - ->andReturn('https://en.gravatar.com/userimage'); - - $provider = Mockery::mock('Laravel\Socialite\PingIdentity\Provider'); - $provider->shouldReceive('user')->andReturn($abstractUser); - - Socialite::shouldReceive('driver')->with('pingidentity')->andReturn($provider); + Socialite::fake('pingidentity', SocialiteUser::fake([ + 'id' => 1234567890, + 'email' => 'cdash@test.com', + 'nickname' => 'Pseudo', + 'name' => 'Arlette Laguiller', + 'avatar' => 'https://en.gravatar.com/userimage', + ])); $response = $this->get('auth/pingidentity/callback'); $response->assertRedirect('/profile'); @@ -388,23 +379,13 @@ public function testPingIdentityProvider(): void public function testNoFullNamePingIdentityProvider(): void { - // Stolen from: https://laracasts.com/discuss/channels/testing/testing-laravel-socialite-callback - $abstractUser = Mockery::mock('Laravel\Socialite\Two\User'); - $abstractUser->shouldReceive('getId') - ->andReturn(1234567890) - ->shouldReceive('getEmail') - ->andReturn('cdash@test.com') - ->shouldReceive('getNickname') - ->andReturn('Pseudo') - ->shouldReceive('getName') - ->andReturn('Pseudo') - ->shouldReceive('getAvatar') - ->andReturn('https://en.gravatar.com/userimage'); - - $provider = Mockery::mock('Laravel\Socialite\PingIdentity\Provider'); - $provider->shouldReceive('user')->andReturn($abstractUser); - - Socialite::shouldReceive('driver')->with('pingidentity')->andReturn($provider); + Socialite::fake('pingidentity', SocialiteUser::fake([ + 'id' => 1234567890, + 'email' => 'cdash@test.com', + 'nickname' => 'Pseudo', + 'name' => 'Pseudo', + 'avatar' => 'https://en.gravatar.com/userimage', + ])); $response = $this->get('auth/pingidentity/callback'); $response->assertRedirect('/profile');