From 2fcf0a7e7a8fd75ff79ac94a441926deb2a78c33 Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Tue, 14 Apr 2026 14:44:15 -0300 Subject: [PATCH] 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. --- tests/Feature/Social/FacebookControllerTest.php | 14 ++++++++------ tests/Feature/Social/InstagramControllerTest.php | 13 +++++++------ tests/Feature/Social/LinkedInControllerTest.php | 13 +++++++------ .../Feature/Social/LinkedInPageControllerTest.php | 15 ++++++++------- tests/Feature/Social/PinterestControllerTest.php | 13 +++++++------ tests/Feature/Social/TikTokControllerTest.php | 13 +++++++------ tests/Feature/Social/XControllerTest.php | 13 +++++++------ tests/Feature/Social/YouTubeControllerTest.php | 15 ++++++++------- 8 files changed, 59 insertions(+), 50 deletions(-) diff --git a/tests/Feature/Social/FacebookControllerTest.php b/tests/Feature/Social/FacebookControllerTest.php index d95cb690..abb0d747 100644 --- a/tests/Feature/Social/FacebookControllerTest.php +++ b/tests/Feature/Social/FacebookControllerTest.php @@ -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') diff --git a/tests/Feature/Social/InstagramControllerTest.php b/tests/Feature/Social/InstagramControllerTest.php index 20b3a2d8..b0117173 100644 --- a/tests/Feature/Social/InstagramControllerTest.php +++ b/tests/Feature/Social/InstagramControllerTest.php @@ -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') diff --git a/tests/Feature/Social/LinkedInControllerTest.php b/tests/Feature/Social/LinkedInControllerTest.php index 6ced6a71..26aee84a 100644 --- a/tests/Feature/Social/LinkedInControllerTest.php +++ b/tests/Feature/Social/LinkedInControllerTest.php @@ -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') diff --git a/tests/Feature/Social/LinkedInPageControllerTest.php b/tests/Feature/Social/LinkedInPageControllerTest.php index e4517af3..ce703bfa 100644 --- a/tests/Feature/Social/LinkedInPageControllerTest.php +++ b/tests/Feature/Social/LinkedInPageControllerTest.php @@ -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') diff --git a/tests/Feature/Social/PinterestControllerTest.php b/tests/Feature/Social/PinterestControllerTest.php index 1ee6b7e4..0336d742 100644 --- a/tests/Feature/Social/PinterestControllerTest.php +++ b/tests/Feature/Social/PinterestControllerTest.php @@ -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') diff --git a/tests/Feature/Social/TikTokControllerTest.php b/tests/Feature/Social/TikTokControllerTest.php index 707777b2..1df0a79f 100644 --- a/tests/Feature/Social/TikTokControllerTest.php +++ b/tests/Feature/Social/TikTokControllerTest.php @@ -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') diff --git a/tests/Feature/Social/XControllerTest.php b/tests/Feature/Social/XControllerTest.php index 1cdac102..7af106d8 100644 --- a/tests/Feature/Social/XControllerTest.php +++ b/tests/Feature/Social/XControllerTest.php @@ -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') diff --git a/tests/Feature/Social/YouTubeControllerTest.php b/tests/Feature/Social/YouTubeControllerTest.php index 21db5603..1d8532f7 100644 --- a/tests/Feature/Social/YouTubeControllerTest.php +++ b/tests/Feature/Social/YouTubeControllerTest.php @@ -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')