From 20e2753dd30344b4017f4b289627c6ac39fa762d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Tue, 23 Oct 2018 11:06:01 +0300 Subject: [PATCH 01/20] Line breaks in an array --- src/Two/AbstractProvider.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Two/AbstractProvider.php b/src/Two/AbstractProvider.php index 4b337a93..a09180ad 100644 --- a/src/Two/AbstractProvider.php +++ b/src/Two/AbstractProvider.php @@ -176,7 +176,8 @@ protected function buildAuthUrlFromBase($url, $state) protected function getCodeFields($state = null) { $fields = [ - 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUrl, + 'client_id' => $this->clientId, + 'redirect_uri' => $this->redirectUrl, 'scope' => $this->formatScopes($this->getScopes(), $this->scopeSeparator), 'response_type' => 'code', ]; @@ -276,8 +277,10 @@ public function getAccessTokenResponse($code) protected function getTokenFields($code) { return [ - 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, - 'code' => $code, 'redirect_uri' => $this->redirectUrl, + 'client_id' => $this->clientId, + 'client_secret' => $this->clientSecret, + 'code' => $code, + 'redirect_uri' => $this->redirectUrl, ]; } From 273e442a7bb05aaa465972cc0142ee0362d71e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Tue, 23 Oct 2018 11:31:59 +0300 Subject: [PATCH 02/20] Update AbstractProvider.php --- src/Two/AbstractProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Two/AbstractProvider.php b/src/Two/AbstractProvider.php index a09180ad..9dab53a0 100644 --- a/src/Two/AbstractProvider.php +++ b/src/Two/AbstractProvider.php @@ -176,7 +176,7 @@ protected function buildAuthUrlFromBase($url, $state) protected function getCodeFields($state = null) { $fields = [ - 'client_id' => $this->clientId, + 'client_id' => $this->clientId, 'redirect_uri' => $this->redirectUrl, 'scope' => $this->formatScopes($this->getScopes(), $this->scopeSeparator), 'response_type' => 'code', @@ -277,9 +277,9 @@ public function getAccessTokenResponse($code) protected function getTokenFields($code) { return [ - 'client_id' => $this->clientId, + 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, - 'code' => $code, + 'code' => $code, 'redirect_uri' => $this->redirectUrl, ]; } From 4ff751816541ea9cde98df8986d79da377aacb7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Wed, 24 Oct 2018 11:11:49 +0300 Subject: [PATCH 03/20] Update BitbucketProvider.php --- src/Two/BitbucketProvider.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Two/BitbucketProvider.php b/src/Two/BitbucketProvider.php index 96a816c5..6805cafe 100644 --- a/src/Two/BitbucketProvider.php +++ b/src/Two/BitbucketProvider.php @@ -87,8 +87,10 @@ protected function getEmailByToken($token) protected function mapUserToObject(array $user) { return (new User)->setRaw($user)->map([ - 'id' => $user['uuid'], 'nickname' => $user['username'], - 'name' => Arr::get($user, 'display_name'), 'email' => Arr::get($user, 'email'), + 'id' => $user['uuid'], + 'nickname' => $user['username'], + 'name' => Arr::get($user, 'display_name'), + 'email' => Arr::get($user, 'email'), 'avatar' => Arr::get($user, 'links.avatar.href'), ]); } From 091d7634ee71daa40464ce83e38571d315cf1da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Wed, 24 Oct 2018 11:13:47 +0300 Subject: [PATCH 04/20] Update FacebookProvider.php --- src/Two/FacebookProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Two/FacebookProvider.php b/src/Two/FacebookProvider.php index fcee468f..1ff199c8 100644 --- a/src/Two/FacebookProvider.php +++ b/src/Two/FacebookProvider.php @@ -111,8 +111,11 @@ protected function mapUserToObject(array $user) $avatarUrl = $this->graphUrl.'/'.$this->version.'/'.$user['id'].'/picture'; return (new User)->setRaw($user)->map([ - 'id' => $user['id'], 'nickname' => null, 'name' => isset($user['name']) ? $user['name'] : null, - 'email' => isset($user['email']) ? $user['email'] : null, 'avatar' => $avatarUrl.'?type=normal', + 'id' => $user['id'], + 'nickname' => null, + 'name' => isset($user['name']) ? $user['name'] : null, + 'email' => isset($user['email']) ? $user['email'] : null, + 'avatar' => $avatarUrl.'?type=normal', 'avatar_original' => $avatarUrl.'?width=1920', 'profileUrl' => isset($user['link']) ? $user['link'] : null, ]); From 83f4d04353ae1ccf4c3dfd8a855e8946c9da762a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Wed, 24 Oct 2018 11:14:32 +0300 Subject: [PATCH 05/20] Update GithubProvider.php --- src/Two/GithubProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Two/GithubProvider.php b/src/Two/GithubProvider.php index 554054ab..650ac2d9 100644 --- a/src/Two/GithubProvider.php +++ b/src/Two/GithubProvider.php @@ -81,8 +81,11 @@ protected function getEmailByToken($token) protected function mapUserToObject(array $user) { return (new User)->setRaw($user)->map([ - 'id' => $user['id'], 'nickname' => $user['login'], 'name' => Arr::get($user, 'name'), - 'email' => Arr::get($user, 'email'), 'avatar' => $user['avatar_url'], + 'id' => $user['id'], + 'nickname' => $user['login'], + 'name' => Arr::get($user, 'name'), + 'email' => Arr::get($user, 'email'), + 'avatar' => $user['avatar_url'], ]); } From ec89a72505ed2e3d7cf098a8dd18e86b392c1433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Wed, 24 Oct 2018 11:15:05 +0300 Subject: [PATCH 06/20] Update FacebookProvider.php --- src/Two/FacebookProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Two/FacebookProvider.php b/src/Two/FacebookProvider.php index 1ff199c8..420dfb22 100644 --- a/src/Two/FacebookProvider.php +++ b/src/Two/FacebookProvider.php @@ -111,7 +111,7 @@ protected function mapUserToObject(array $user) $avatarUrl = $this->graphUrl.'/'.$this->version.'/'.$user['id'].'/picture'; return (new User)->setRaw($user)->map([ - 'id' => $user['id'], + 'id' => $user['id'], 'nickname' => null, 'name' => isset($user['name']) ? $user['name'] : null, 'email' => isset($user['email']) ? $user['email'] : null, From 37db0ae9ecc4e67cbb5f74b29fb8076a390721c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Wed, 24 Oct 2018 11:17:41 +0300 Subject: [PATCH 07/20] Update GoogleProvider.php --- src/Two/GoogleProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Two/GoogleProvider.php b/src/Two/GoogleProvider.php index 9cb9a5e2..c14aa349 100644 --- a/src/Two/GoogleProvider.php +++ b/src/Two/GoogleProvider.php @@ -79,8 +79,11 @@ protected function mapUserToObject(array $user) $avatarUrl = Arr::get($user, 'image.url'); return (new User)->setRaw($user)->map([ - 'id' => $user['id'], 'nickname' => Arr::get($user, 'nickname'), 'name' => $user['displayName'], - 'email' => Arr::get($user, 'emails.0.value'), 'avatar' => $avatarUrl, + 'id' => $user['id'], + 'nickname' => Arr::get($user, 'nickname'), + 'name' => $user['displayName'], + 'email' => Arr::get($user, 'emails.0.value'), + 'avatar' => $avatarUrl, 'avatar_original' => preg_replace('/\?sz=([0-9]+)/', '', $avatarUrl), ]); } From ea399a2157230a79f7af9f9733847eabd93f19a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Wed, 24 Oct 2018 11:18:34 +0300 Subject: [PATCH 08/20] Update LinkedInProvider.php --- src/Two/LinkedInProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Two/LinkedInProvider.php b/src/Two/LinkedInProvider.php index 526cc050..f8ac6cd4 100644 --- a/src/Two/LinkedInProvider.php +++ b/src/Two/LinkedInProvider.php @@ -83,8 +83,11 @@ protected function getUserByToken($token) protected function mapUserToObject(array $user) { return (new User)->setRaw($user)->map([ - 'id' => $user['id'], 'nickname' => null, 'name' => Arr::get($user, 'formattedName'), - 'email' => Arr::get($user, 'emailAddress'), 'avatar' => Arr::get($user, 'pictureUrl'), + 'id' => $user['id'], + 'nickname' => null, + 'name' => Arr::get($user, 'formattedName'), + 'email' => Arr::get($user, 'emailAddress'), + 'avatar' => Arr::get($user, 'pictureUrl'), 'avatar_original' => Arr::get($user, 'pictureUrls.values.0'), ]); } From e046f68fee013bec6bfa1e39de71809022122bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Wed, 24 Oct 2018 11:24:49 +0300 Subject: [PATCH 09/20] Update TwitterProvider.php --- src/One/TwitterProvider.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/One/TwitterProvider.php b/src/One/TwitterProvider.php index c7440286..64bf4cb0 100644 --- a/src/One/TwitterProvider.php +++ b/src/One/TwitterProvider.php @@ -26,8 +26,11 @@ public function user() ->setToken($token->getIdentifier(), $token->getSecret()); return $instance->map([ - 'id' => $user->uid, 'nickname' => $user->nickname, - 'name' => $user->name, 'email' => $user->email, 'avatar' => $user->imageUrl, + 'id' => $user->uid, + 'nickname' => $user->nickname, + 'name' => $user->name, + 'email' => $user->email, + 'avatar' => $user->imageUrl, 'avatar_original' => str_replace('_normal', '', $user->imageUrl), ]); } From d393c8ee453d651593cc7688e49904e4e99502e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BB=D1=8C=D1=8F?= Date: Wed, 24 Oct 2018 11:26:01 +0300 Subject: [PATCH 10/20] Update AbstractProvider.php --- src/One/AbstractProvider.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/One/AbstractProvider.php b/src/One/AbstractProvider.php index 1a1b2c03..f85ba126 100644 --- a/src/One/AbstractProvider.php +++ b/src/One/AbstractProvider.php @@ -81,8 +81,11 @@ public function user() ->setToken($token->getIdentifier(), $token->getSecret()); return $instance->map([ - 'id' => $user->uid, 'nickname' => $user->nickname, - 'name' => $user->name, 'email' => $user->email, 'avatar' => $user->imageUrl, + 'id' => $user->uid, + 'nickname' => $user->nickname, + 'name' => $user->name, + 'email' => $user->email, + 'avatar' => $user->imageUrl, ]); } @@ -108,8 +111,11 @@ public function userFromTokenAndSecret($token, $secret) ->setToken($tokenCredentials->getIdentifier(), $tokenCredentials->getSecret()); return $instance->map([ - 'id' => $user->uid, 'nickname' => $user->nickname, - 'name' => $user->name, 'email' => $user->email, 'avatar' => $user->imageUrl, + 'id' => $user->uid, + 'nickname' => $user->nickname, + 'name' => $user->name, + 'email' => $user->email, + 'avatar' => $user->imageUrl, ]); } From 2ed67597267e4702953fd0f57e9e628750c4e237 Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Fri, 9 Nov 2018 09:54:12 +0100 Subject: [PATCH 11/20] Avoid FQCN and prefer imports. --- src/SocialiteManager.php | 3 +- tests/Fixtures/FacebookTestProviderStub.php | 3 +- tests/Fixtures/OAuthTwoTestProviderStub.php | 3 +- tests/OAuthOneTest.php | 32 +++++++++++++-------- tests/OAuthTwoTest.php | 32 ++++++++++++--------- 5 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/SocialiteManager.php b/src/SocialiteManager.php index 53d9e303..826a6bb3 100644 --- a/src/SocialiteManager.php +++ b/src/SocialiteManager.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Illuminate\Support\Manager; use Laravel\Socialite\Two\GithubProvider; +use Laravel\Socialite\Two\GitlabProvider; use Laravel\Socialite\Two\GoogleProvider; use Laravel\Socialite\One\TwitterProvider; use Laravel\Socialite\Two\FacebookProvider; @@ -107,7 +108,7 @@ protected function createGitlabDriver() $config = $this->app['config']['services.gitlab']; return $this->buildProvider( - \Laravel\Socialite\Two\GitlabProvider::class, $config + GitlabProvider::class, $config ); } diff --git a/tests/Fixtures/FacebookTestProviderStub.php b/tests/Fixtures/FacebookTestProviderStub.php index 91f1a1bb..6c777183 100644 --- a/tests/Fixtures/FacebookTestProviderStub.php +++ b/tests/Fixtures/FacebookTestProviderStub.php @@ -4,6 +4,7 @@ use Mockery as m; use Laravel\Socialite\Two\FacebookProvider; +use stdClass; class FacebookTestProviderStub extends FacebookProvider { @@ -28,6 +29,6 @@ protected function getHttpClient() return $this->http; } - return $this->http = m::mock(\stdClass::class); + return $this->http = m::mock(stdClass::class); } } diff --git a/tests/Fixtures/OAuthTwoTestProviderStub.php b/tests/Fixtures/OAuthTwoTestProviderStub.php index e9707d40..d5d5b73c 100644 --- a/tests/Fixtures/OAuthTwoTestProviderStub.php +++ b/tests/Fixtures/OAuthTwoTestProviderStub.php @@ -5,6 +5,7 @@ use Mockery as m; use Laravel\Socialite\Two\User; use Laravel\Socialite\Two\AbstractProvider; +use stdClass; class OAuthTwoTestProviderStub extends AbstractProvider { @@ -44,6 +45,6 @@ protected function getHttpClient() return $this->http; } - return $this->http = m::mock(\stdClass::class); + return $this->http = m::mock(stdClass::class); } } diff --git a/tests/OAuthOneTest.php b/tests/OAuthOneTest.php index a1774841..27bbf4d4 100644 --- a/tests/OAuthOneTest.php +++ b/tests/OAuthOneTest.php @@ -2,9 +2,17 @@ namespace Tests; +use Illuminate\Contracts\Session\Session; +use Illuminate\Http\RedirectResponse; +use Laravel\Socialite\One\User as SocialiteUser; +use League\OAuth1\Client\Credentials\TemporaryCredentials; +use League\OAuth1\Client\Credentials\TokenCredentials; +use League\OAuth1\Client\Server\Twitter; +use League\OAuth1\Client\Server\User; use Mockery as m; use Illuminate\Http\Request; use PHPUnit_Framework_TestCase; +use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse; use Tests\Fixtures\OAuthOneTestProviderStub; class OAuthOneTest extends PHPUnit_Framework_TestCase @@ -16,41 +24,41 @@ public function tearDown() public function testRedirectGeneratesTheProperIlluminateRedirectResponse() { - $server = m::mock(\League\OAuth1\Client\Server\Twitter::class); + $server = m::mock(Twitter::class); $server->shouldReceive('getTemporaryCredentials')->once()->andReturn('temp'); $server->shouldReceive('getAuthorizationUrl')->once()->with('temp')->andReturn('http://auth.url'); $request = Request::create('foo'); - $request->setLaravelSession($session = m::mock(\Illuminate\Contracts\Session\Session::class)); + $request->setLaravelSession($session = m::mock(Session::class)); $session->shouldReceive('put')->once()->with('oauth.temp', 'temp'); $provider = new OAuthOneTestProviderStub($request, $server); $response = $provider->redirect(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); - $this->assertInstanceOf('Illuminate\Http\RedirectResponse', $response); + $this->assertInstanceOf(SymfonyRedirectResponse::class, $response); + $this->assertInstanceOf(RedirectResponse::class, $response); } public function testUserReturnsAUserInstanceForTheAuthenticatedRequest() { - $server = m::mock(\League\OAuth1\Client\Server\Twitter::class); - $temp = m::mock(\League\OAuth1\Client\Credentials\TemporaryCredentials::class); + $server = m::mock(Twitter::class); + $temp = m::mock(TemporaryCredentials::class); $server->shouldReceive('getTokenCredentials')->once()->with($temp, 'oauth_token', 'oauth_verifier')->andReturn( - $token = m::mock(\League\OAuth1\Client\Credentials\TokenCredentials::class) + $token = m::mock(TokenCredentials::class) ); - $server->shouldReceive('getUserDetails')->once()->with($token, false)->andReturn($user = m::mock(\League\OAuth1\Client\Server\User::class)); + $server->shouldReceive('getUserDetails')->once()->with($token, false)->andReturn($user = m::mock(User::class)); $token->shouldReceive('getIdentifier')->twice()->andReturn('identifier'); $token->shouldReceive('getSecret')->twice()->andReturn('secret'); $user->uid = 'uid'; $user->email = 'foo@bar.com'; $user->extra = ['extra' => 'extra']; $request = Request::create('foo', 'GET', ['oauth_token' => 'oauth_token', 'oauth_verifier' => 'oauth_verifier']); - $request->setLaravelSession($session = m::mock(\Illuminate\Contracts\Session\Session::class)); + $request->setLaravelSession($session = m::mock(Session::class)); $session->shouldReceive('get')->once()->with('oauth.temp')->andReturn($temp); $provider = new OAuthOneTestProviderStub($request, $server); $user = $provider->user(); - $this->assertInstanceOf('Laravel\Socialite\One\User', $user); + $this->assertInstanceOf(SocialiteUser::class, $user); $this->assertSame('uid', $user->id); $this->assertSame('foo@bar.com', $user->email); $this->assertSame(['extra' => 'extra'], $user->user); @@ -61,9 +69,9 @@ public function testUserReturnsAUserInstanceForTheAuthenticatedRequest() */ public function testExceptionIsThrownWhenVerifierIsMissing() { - $server = m::mock(\League\OAuth1\Client\Server\Twitter::class); + $server = m::mock(Twitter::class); $request = Request::create('foo'); - $request->setLaravelSession($session = m::mock(\Illuminate\Contracts\Session\Session::class)); + $request->setLaravelSession($session = m::mock(Session::class)); $provider = new OAuthOneTestProviderStub($request, $server); $provider->user(); diff --git a/tests/OAuthTwoTest.php b/tests/OAuthTwoTest.php index 43fd1185..1e17ab03 100644 --- a/tests/OAuthTwoTest.php +++ b/tests/OAuthTwoTest.php @@ -2,10 +2,16 @@ namespace Tests; +use Illuminate\Contracts\Session\Session; +use Illuminate\Http\RedirectResponse; +use Laravel\Socialite\Two\User; use Mockery as m; use Illuminate\Http\Request; use GuzzleHttp\ClientInterface; use PHPUnit_Framework_TestCase; +use stdClass; +use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse; +use Symfony\Component\HttpFoundation\Session\SessionInterface; use Tests\Fixtures\FacebookTestProviderStub; use Tests\Fixtures\OAuthTwoTestProviderStub; @@ -19,31 +25,31 @@ public function tearDown() public function testRedirectGeneratesTheProperIlluminateRedirectResponse() { $request = Request::create('foo'); - $request->setLaravelSession($session = m::mock(\Illuminate\Contracts\Session\Session::class)); + $request->setLaravelSession($session = m::mock(Session::class)); $session->shouldReceive('put')->once(); $provider = new OAuthTwoTestProviderStub($request, 'client_id', 'client_secret', 'redirect'); $response = $provider->redirect(); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); - $this->assertInstanceOf('Illuminate\Http\RedirectResponse', $response); + $this->assertInstanceOf(SymfonyRedirectResponse::class, $response); + $this->assertInstanceOf(RedirectResponse::class, $response); $this->assertSame('http://auth.url', $response->getTargetUrl()); } public function testUserReturnsAUserInstanceForTheAuthenticatedRequest() { $request = Request::create('foo', 'GET', ['state' => str_repeat('A', 40), 'code' => 'code']); - $request->setLaravelSession($session = m::mock(\Illuminate\Contracts\Session\Session::class)); + $request->setLaravelSession($session = m::mock(Session::class)); $session->shouldReceive('pull')->once()->with('state')->andReturn(str_repeat('A', 40)); $provider = new OAuthTwoTestProviderStub($request, 'client_id', 'client_secret', 'redirect_uri'); - $provider->http = m::mock(\stdClass::class); + $provider->http = m::mock(stdClass::class); $postKey = (version_compare(ClientInterface::VERSION, '6') === 1) ? 'form_params' : 'body'; $provider->http->shouldReceive('post')->once()->with('http://token.url', [ 'headers' => ['Accept' => 'application/json'], $postKey => ['client_id' => 'client_id', 'client_secret' => 'client_secret', 'code' => 'code', 'redirect_uri' => 'redirect_uri'], - ])->andReturn($response = m::mock(\stdClass::class)); + ])->andReturn($response = m::mock(stdClass::class)); $response->shouldReceive('getBody')->once()->andReturn('{ "access_token" : "access_token", "refresh_token" : "refresh_token", "expires_in" : 3600 }'); $user = $provider->user(); - $this->assertInstanceOf('Laravel\Socialite\Two\User', $user); + $this->assertInstanceOf(User::class, $user); $this->assertSame('foo', $user->id); $this->assertSame('access_token', $user->token); $this->assertSame('refresh_token', $user->refreshToken); @@ -53,18 +59,18 @@ public function testUserReturnsAUserInstanceForTheAuthenticatedRequest() public function testUserReturnsAUserInstanceForTheAuthenticatedFacebookRequest() { $request = Request::create('foo', 'GET', ['state' => str_repeat('A', 40), 'code' => 'code']); - $request->setSession($session = m::mock(\Symfony\Component\HttpFoundation\Session\SessionInterface::class)); + $request->setSession($session = m::mock(SessionInterface::class)); $session->shouldReceive('pull')->once()->with('state')->andReturn(str_repeat('A', 40)); $provider = new FacebookTestProviderStub($request, 'client_id', 'client_secret', 'redirect_uri'); - $provider->http = m::mock(\stdClass::class); + $provider->http = m::mock(stdClass::class); $postKey = (version_compare(ClientInterface::VERSION, '6') === 1) ? 'form_params' : 'body'; $provider->http->shouldReceive('post')->once()->with('https://graph.facebook.com/v3.0/oauth/access_token', [ $postKey => ['client_id' => 'client_id', 'client_secret' => 'client_secret', 'code' => 'code', 'redirect_uri' => 'redirect_uri'], - ])->andReturn($response = m::mock(\stdClass::class)); + ])->andReturn($response = m::mock(stdClass::class)); $response->shouldReceive('getBody')->once()->andReturn(json_encode(['access_token' => 'access_token', 'expires' => 5183085])); $user = $provider->user(); - $this->assertInstanceOf('Laravel\Socialite\Two\User', $user); + $this->assertInstanceOf(User::class, $user); $this->assertSame('foo', $user->id); $this->assertSame('access_token', $user->token); $this->assertNull($user->refreshToken); @@ -77,7 +83,7 @@ public function testUserReturnsAUserInstanceForTheAuthenticatedFacebookRequest() public function testExceptionIsThrownIfStateIsInvalid() { $request = Request::create('foo', 'GET', ['state' => str_repeat('B', 40), 'code' => 'code']); - $request->setLaravelSession($session = m::mock(\Illuminate\Contracts\Session\Session::class)); + $request->setLaravelSession($session = m::mock(Session::class)); $session->shouldReceive('pull')->once()->with('state')->andReturn(str_repeat('A', 40)); $provider = new OAuthTwoTestProviderStub($request, 'client_id', 'client_secret', 'redirect'); $provider->user(); @@ -89,7 +95,7 @@ public function testExceptionIsThrownIfStateIsInvalid() public function testExceptionIsThrownIfStateIsNotSet() { $request = Request::create('foo', 'GET', ['state' => 'state', 'code' => 'code']); - $request->setLaravelSession($session = m::mock(\Illuminate\Contracts\Session\Session::class)); + $request->setLaravelSession($session = m::mock(Session::class)); $session->shouldReceive('pull')->once()->with('state'); $provider = new OAuthTwoTestProviderStub($request, 'client_id', 'client_secret', 'redirect'); $provider->user(); From a5039b74a41507f739ad8ebc86e9afad557d9291 Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Fri, 9 Nov 2018 09:56:07 +0100 Subject: [PATCH 12/20] Fix CS. --- tests/Fixtures/FacebookTestProviderStub.php | 2 +- tests/Fixtures/OAuthTwoTestProviderStub.php | 2 +- tests/OAuthOneTest.php | 16 ++++++++-------- tests/OAuthTwoTest.php | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/Fixtures/FacebookTestProviderStub.php b/tests/Fixtures/FacebookTestProviderStub.php index 6c777183..946001ab 100644 --- a/tests/Fixtures/FacebookTestProviderStub.php +++ b/tests/Fixtures/FacebookTestProviderStub.php @@ -2,9 +2,9 @@ namespace Tests\Fixtures; +use stdClass; use Mockery as m; use Laravel\Socialite\Two\FacebookProvider; -use stdClass; class FacebookTestProviderStub extends FacebookProvider { diff --git a/tests/Fixtures/OAuthTwoTestProviderStub.php b/tests/Fixtures/OAuthTwoTestProviderStub.php index d5d5b73c..94a018e5 100644 --- a/tests/Fixtures/OAuthTwoTestProviderStub.php +++ b/tests/Fixtures/OAuthTwoTestProviderStub.php @@ -2,10 +2,10 @@ namespace Tests\Fixtures; +use stdClass; use Mockery as m; use Laravel\Socialite\Two\User; use Laravel\Socialite\Two\AbstractProvider; -use stdClass; class OAuthTwoTestProviderStub extends AbstractProvider { diff --git a/tests/OAuthOneTest.php b/tests/OAuthOneTest.php index 27bbf4d4..343f37bb 100644 --- a/tests/OAuthOneTest.php +++ b/tests/OAuthOneTest.php @@ -2,18 +2,18 @@ namespace Tests; -use Illuminate\Contracts\Session\Session; -use Illuminate\Http\RedirectResponse; -use Laravel\Socialite\One\User as SocialiteUser; -use League\OAuth1\Client\Credentials\TemporaryCredentials; -use League\OAuth1\Client\Credentials\TokenCredentials; -use League\OAuth1\Client\Server\Twitter; -use League\OAuth1\Client\Server\User; use Mockery as m; use Illuminate\Http\Request; use PHPUnit_Framework_TestCase; -use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse; +use Illuminate\Http\RedirectResponse; +use League\OAuth1\Client\Server\User; +use League\OAuth1\Client\Server\Twitter; +use Illuminate\Contracts\Session\Session; use Tests\Fixtures\OAuthOneTestProviderStub; +use Laravel\Socialite\One\User as SocialiteUser; +use League\OAuth1\Client\Credentials\TokenCredentials; +use League\OAuth1\Client\Credentials\TemporaryCredentials; +use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse; class OAuthOneTest extends PHPUnit_Framework_TestCase { diff --git a/tests/OAuthTwoTest.php b/tests/OAuthTwoTest.php index 1e17ab03..52835281 100644 --- a/tests/OAuthTwoTest.php +++ b/tests/OAuthTwoTest.php @@ -2,18 +2,18 @@ namespace Tests; -use Illuminate\Contracts\Session\Session; -use Illuminate\Http\RedirectResponse; -use Laravel\Socialite\Two\User; +use stdClass; use Mockery as m; use Illuminate\Http\Request; use GuzzleHttp\ClientInterface; +use Laravel\Socialite\Two\User; use PHPUnit_Framework_TestCase; -use stdClass; -use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse; -use Symfony\Component\HttpFoundation\Session\SessionInterface; +use Illuminate\Http\RedirectResponse; +use Illuminate\Contracts\Session\Session; use Tests\Fixtures\FacebookTestProviderStub; use Tests\Fixtures\OAuthTwoTestProviderStub; +use Symfony\Component\HttpFoundation\Session\SessionInterface; +use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse; class OAuthTwoTest extends PHPUnit_Framework_TestCase { From 405e739ed050e357fb3ba19864d90241c786f9cd Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Sat, 10 Nov 2018 19:14:53 +0100 Subject: [PATCH 13/20] No need to use array_add() helper. --- src/Two/GoogleProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Two/GoogleProvider.php b/src/Two/GoogleProvider.php index c14aa349..16f6c907 100644 --- a/src/Two/GoogleProvider.php +++ b/src/Two/GoogleProvider.php @@ -48,7 +48,7 @@ protected function getTokenUrl() */ protected function getTokenFields($code) { - return array_add( + return Arr::add( parent::getTokenFields($code), 'grant_type', 'authorization_code' ); } From a90efb03da8fe562f2ae650fabd3eb3a3c78c246 Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Sat, 10 Nov 2018 19:24:45 +0100 Subject: [PATCH 14/20] Use modern phpunit TestCase namesapce. --- tests/OAuthOneTest.php | 4 ++-- tests/OAuthTwoTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/OAuthOneTest.php b/tests/OAuthOneTest.php index 343f37bb..387dd76f 100644 --- a/tests/OAuthOneTest.php +++ b/tests/OAuthOneTest.php @@ -4,7 +4,7 @@ use Mockery as m; use Illuminate\Http\Request; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Illuminate\Http\RedirectResponse; use League\OAuth1\Client\Server\User; use League\OAuth1\Client\Server\Twitter; @@ -15,7 +15,7 @@ use League\OAuth1\Client\Credentials\TemporaryCredentials; use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse; -class OAuthOneTest extends PHPUnit_Framework_TestCase +class OAuthOneTest extends TestCase { public function tearDown() { diff --git a/tests/OAuthTwoTest.php b/tests/OAuthTwoTest.php index 52835281..520e3b1c 100644 --- a/tests/OAuthTwoTest.php +++ b/tests/OAuthTwoTest.php @@ -7,7 +7,7 @@ use Illuminate\Http\Request; use GuzzleHttp\ClientInterface; use Laravel\Socialite\Two\User; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Illuminate\Http\RedirectResponse; use Illuminate\Contracts\Session\Session; use Tests\Fixtures\FacebookTestProviderStub; @@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\RedirectResponse as SymfonyRedirectResponse; -class OAuthTwoTest extends PHPUnit_Framework_TestCase +class OAuthTwoTest extends TestCase { public function tearDown() { From 7d4f4a2de2266c0ad6dce368820dd49fcd3797ba Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Sat, 10 Nov 2018 19:26:26 +0100 Subject: [PATCH 15/20] Fix tearDown visibility. --- tests/OAuthOneTest.php | 5 ++++- tests/OAuthTwoTest.php | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/OAuthOneTest.php b/tests/OAuthOneTest.php index 343f37bb..106cb7c6 100644 --- a/tests/OAuthOneTest.php +++ b/tests/OAuthOneTest.php @@ -17,8 +17,11 @@ class OAuthOneTest extends PHPUnit_Framework_TestCase { - public function tearDown() + protected function tearDown() { + + parent::tearDown(); + m::close(); } diff --git a/tests/OAuthTwoTest.php b/tests/OAuthTwoTest.php index 52835281..5e3a9e23 100644 --- a/tests/OAuthTwoTest.php +++ b/tests/OAuthTwoTest.php @@ -17,8 +17,10 @@ class OAuthTwoTest extends PHPUnit_Framework_TestCase { - public function tearDown() + protected function tearDown() { + parent::tearDown(); + m::close(); } From 394d37fff1d9304c475520daa329e0e1307744fe Mon Sep 17 00:00:00 2001 From: Lucas Michot Date: Sat, 10 Nov 2018 19:27:14 +0100 Subject: [PATCH 16/20] Fix CS. --- tests/OAuthOneTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/OAuthOneTest.php b/tests/OAuthOneTest.php index 106cb7c6..d0017e7a 100644 --- a/tests/OAuthOneTest.php +++ b/tests/OAuthOneTest.php @@ -19,7 +19,6 @@ class OAuthOneTest extends PHPUnit_Framework_TestCase { protected function tearDown() { - parent::tearDown(); m::close(); From 8f507d5c2961f0aa2c4c4252249db516e6d0f413 Mon Sep 17 00:00:00 2001 From: Andrey Bolonin Date: Sun, 11 Nov 2018 01:31:58 +0200 Subject: [PATCH 17/20] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 326a36f4..e5fee123 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ php: - 7.0 - 7.1 - 7.2 + - 7.3 sudo: false From f031670a5472fbe0e5f2069e77cb88277146392d Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 23 Nov 2018 21:23:41 +0100 Subject: [PATCH 18/20] Disable xdebug --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index e5fee123..aa77902f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,9 @@ php: sudo: false +before_install: + - phpenv config-rm xdebug.ini || true + install: travis_retry composer install --no-interaction --prefer-dist --no-suggest script: vendor/bin/phpunit --verbose From a1d14956191bbe7f15596e3b206211438ea519a0 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 29 Nov 2018 20:28:56 +0100 Subject: [PATCH 19/20] Remove note about 5.3 5.3 isn't supported anymore. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index f56e3574..6af62318 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,6 @@ Laravel Socialite provides an expressive, fluent interface to OAuth authenticati **We are not accepting new adapters.** -**If you are using Laravel 5.3 or below, please use [Socialite 2.0](https://github.com/laravel/socialite/tree/2.0).** - Adapters for other platforms are listed at the community driven [Socialite Providers](https://socialiteproviders.github.io/) website. ## Official Documentation From ba467221da88433cde7a162b34df813858141d4d Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 6 Dec 2018 20:54:22 +0100 Subject: [PATCH 20/20] Unify test namespaces --- composer.json | 2 +- tests/Fixtures/FacebookTestProviderStub.php | 2 +- tests/Fixtures/OAuthOneTestProviderStub.php | 2 +- tests/Fixtures/OAuthTwoTestProviderStub.php | 2 +- tests/OAuthOneTest.php | 4 ++-- tests/OAuthTwoTest.php | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 14c94eb9..4d31c2f4 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ }, "autoload-dev": { "psr-4": { - "Tests\\": "tests/" + "Laravel\\Socialite\\Tests\\": "tests/" } }, "extra": { diff --git a/tests/Fixtures/FacebookTestProviderStub.php b/tests/Fixtures/FacebookTestProviderStub.php index 946001ab..0cf4e388 100644 --- a/tests/Fixtures/FacebookTestProviderStub.php +++ b/tests/Fixtures/FacebookTestProviderStub.php @@ -1,6 +1,6 @@