Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
49 changes: 15 additions & 34 deletions tests/Feature/LoginAndRegistration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -364,47 +365,27 @@ 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');
}

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');
Expand Down