fix: update Socialite mocks in social controller tests

The mock shorthand Mockery::mock([...]) was not compatible with the
Socialite facade mock. Replaced with explicit shouldReceive chains
matching each controller's actual Socialite method calls.

Also keeps Google OAuth routes always registered so Wayfinder can
generate TypeScript helpers regardless of GOOGLE_AUTH_ENABLED setting.
This commit is contained in:
Paulo Castellano 2026-04-14 14:44:15 -03:00
parent 1a7af9728f
commit 2fcf0a7e7a
8 changed files with 59 additions and 50 deletions

View file

@ -20,14 +20,16 @@
});
test('facebook connect redirects to oauth provider', function () {
$driverMock = Mockery::mock();
$driverMock->shouldReceive('usingGraphVersion')->andReturnSelf();
$driverMock->shouldReceive('setScopes')->andReturnSelf();
$driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([
'getTargetUrl' => 'https://www.facebook.com/v25.0/dialog/oauth?test=1',
]));
Socialite::shouldReceive('driver')
->with('facebook')
->andReturn(Mockery::mock([
'scopes' => Mockery::self(),
'redirect' => Mockery::mock([
'getTargetUrl' => 'https://www.facebook.com/v21.0/dialog/oauth?test=1',
]),
]));
->andReturn($driverMock);
$response = $this->actingAs($this->user)
->withHeader('X-Inertia', 'true')

View file

@ -19,14 +19,15 @@
});
test('instagram connect redirects to oauth provider', function () {
$driverMock = Mockery::mock();
$driverMock->shouldReceive('scopes')->andReturnSelf();
$driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([
'getTargetUrl' => 'https://www.instagram.com/oauth/authorize?test=1',
]));
Socialite::shouldReceive('driver')
->with('instagram')
->andReturn(Mockery::mock([
'scopes' => Mockery::self(),
'redirect' => Mockery::mock([
'getTargetUrl' => 'https://www.instagram.com/oauth/authorize?test=1',
]),
]));
->andReturn($driverMock);
$response = $this->actingAs($this->user)
->withHeader('X-Inertia', 'true')

View file

@ -20,14 +20,15 @@
});
test('linkedin connect redirects to oauth provider', function () {
$driverMock = Mockery::mock();
$driverMock->shouldReceive('scopes')->andReturnSelf();
$driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([
'getTargetUrl' => 'https://www.linkedin.com/oauth/v2/authorization?test=1',
]));
Socialite::shouldReceive('driver')
->with('linkedin')
->andReturn(Mockery::mock([
'scopes' => Mockery::self(),
'redirect' => Mockery::mock([
'getTargetUrl' => 'https://www.linkedin.com/oauth/v2/authorization?test=1',
]),
]));
->andReturn($driverMock);
$response = $this->actingAs($this->user)
->withHeader('X-Inertia', 'true')

View file

@ -20,15 +20,16 @@
});
test('linkedin page connect redirects to oauth provider', function () {
$driverMock = Mockery::mock();
$driverMock->shouldReceive('scopes')->andReturnSelf();
$driverMock->shouldReceive('with')->andReturnSelf();
$driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([
'getTargetUrl' => 'https://www.linkedin.com/oauth/v2/authorization?test=1',
]));
Socialite::shouldReceive('driver')
->with('linkedin-openid')
->andReturn(Mockery::mock([
'scopes' => Mockery::self(),
'with' => Mockery::self(),
'redirect' => Mockery::mock([
'getTargetUrl' => 'https://www.linkedin.com/oauth/v2/authorization?test=1',
]),
]));
->andReturn($driverMock);
$response = $this->actingAs($this->user)
->withHeader('X-Inertia', 'true')

View file

@ -19,14 +19,15 @@
});
test('pinterest connect redirects to oauth provider', function () {
$driverMock = Mockery::mock();
$driverMock->shouldReceive('scopes')->andReturnSelf();
$driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([
'getTargetUrl' => 'https://www.pinterest.com/oauth?test=1',
]));
Socialite::shouldReceive('driver')
->with('pinterest')
->andReturn(Mockery::mock([
'scopes' => Mockery::self(),
'redirect' => Mockery::mock([
'getTargetUrl' => 'https://www.pinterest.com/oauth?test=1',
]),
]));
->andReturn($driverMock);
$response = $this->actingAs($this->user)
->withHeader('X-Inertia', 'true')

View file

@ -19,14 +19,15 @@
});
test('tiktok connect redirects to oauth provider', function () {
$driverMock = Mockery::mock();
$driverMock->shouldReceive('scopes')->andReturnSelf();
$driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([
'getTargetUrl' => 'https://www.tiktok.com/v2/auth/authorize?test=1',
]));
Socialite::shouldReceive('driver')
->with('tiktok')
->andReturn(Mockery::mock([
'scopes' => Mockery::self(),
'redirect' => Mockery::mock([
'getTargetUrl' => 'https://www.tiktok.com/v2/auth/authorize?test=1',
]),
]));
->andReturn($driverMock);
$response = $this->actingAs($this->user)
->withHeader('X-Inertia', 'true')

View file

@ -19,14 +19,15 @@
});
test('x connect redirects to oauth provider', function () {
$driverMock = Mockery::mock();
$driverMock->shouldReceive('scopes')->andReturnSelf();
$driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([
'getTargetUrl' => 'https://twitter.com/i/oauth2/authorize?test=1',
]));
Socialite::shouldReceive('driver')
->with('x')
->andReturn(Mockery::mock([
'scopes' => Mockery::self(),
'redirect' => Mockery::mock([
'getTargetUrl' => 'https://twitter.com/i/oauth2/authorize?test=1',
]),
]));
->andReturn($driverMock);
$response = $this->actingAs($this->user)
->withHeader('X-Inertia', 'true')

View file

@ -20,15 +20,16 @@
});
test('youtube connect redirects to oauth provider', function () {
$driverMock = Mockery::mock();
$driverMock->shouldReceive('scopes')->andReturnSelf();
$driverMock->shouldReceive('with')->andReturnSelf();
$driverMock->shouldReceive('redirect')->andReturn(Mockery::mock([
'getTargetUrl' => 'https://accounts.google.com/o/oauth2/v2/auth?test=1',
]));
Socialite::shouldReceive('driver')
->with('google')
->andReturn(Mockery::mock([
'scopes' => Mockery::self(),
'with' => Mockery::self(),
'redirect' => Mockery::mock([
'getTargetUrl' => 'https://accounts.google.com/o/oauth2/v2/auth?test=1',
]),
]));
->andReturn($driverMock);
$response = $this->actingAs($this->user)
->withHeader('X-Inertia', 'true')