Skip to content

Commit ca741af

Browse files
Copilotovertrue
andcommitted
Add composer fix command using Laravel Pint for code formatting
Co-authored-by: overtrue <[email protected]>
1 parent 579badb commit ca741af

File tree

13 files changed

+144
-149
lines changed

13 files changed

+144
-149
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"scripts": {
4545
"check-style": "@php vendor/bin/pint --test",
4646
"fix-style": "@php vendor/bin/pint",
47+
"fix": "@php vendor/bin/pint",
4748
"test": "@php vendor/bin/phpunit --colors=always",
4849
"phpstan": "@php vendor/bin/phpstan analyse src"
4950
}

src/Providers/Douban.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ protected function getTokenUrl(): string
2424
return 'https://www.douban.com/service/auth2/token';
2525
}
2626

27-
/**
28-
* @param ?array $query
29-
*/
3027
protected function getUserByToken(string $token, ?array $query = []): array
3128
{
3229
$response = $this->getHttpClient()->get('https://api.douban.com/v2/user/~me', [

src/Providers/PayPal.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PayPal extends Base
4242
public function __construct(array $config)
4343
{
4444
parent::__construct($config);
45-
$this->sandbox = (bool)$this->config->get('sandbox', false);
45+
$this->sandbox = (bool) $this->config->get('sandbox', false);
4646
if ($this->sandbox) {
4747
$this->authUrl = 'https://www.sandbox.paypal.com/signin/authorize';
4848
$this->tokenURL = 'https://api-m.sandbox.paypal.com/v1/oauth2/token';
@@ -97,7 +97,6 @@ protected function getTokenUrl(): string
9797
* @throws \Overtrue\Socialite\Exceptions\AuthorizeFailedException
9898
*
9999
* @see https://developer.paypal.com/docs/log-in-with-paypal/integrate/#link-getaccesstoken
100-
*
101100
*/
102101
public function tokenFromCode(string $code): array
103102
{
@@ -110,11 +109,12 @@ public function tokenFromCode(string $code): array
110109
],
111110
'headers' => [
112111
'Accept' => 'application/json',
113-
'Authorization' => 'Basic ' . \base64_encode(\sprintf('%s:%s', $this->getClientId(), $this->getClientSecret())),
112+
'Authorization' => 'Basic '.\base64_encode(\sprintf('%s:%s', $this->getClientId(), $this->getClientSecret())),
114113
],
115114
]
116115
);
117-
return $this->normalizeAccessTokenResponse((string)$response->getBody());
116+
117+
return $this->normalizeAccessTokenResponse((string) $response->getBody());
118118
}
119119

120120
/**
@@ -129,10 +129,11 @@ protected function getUserByToken(string $token): array
129129
[
130130
'headers' => [
131131
'Content-Type' => 'application/x-www-form-urlencoded',
132-
'Authorization' => 'Bearer ' . $token,
132+
'Authorization' => 'Bearer '.$token,
133133
],
134134
]
135135
);
136+
136137
return $this->fromJsonBody($response);
137138
}
138139

tests/OAuthTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class OAuthTest extends TestCase
99
{
10-
public function tearDown(): void
10+
protected function tearDown(): void
1111
{
1212
m::close();
1313
}
@@ -130,7 +130,7 @@ public function test_it_can_get_user_by_code()
130130

131131
$response = m::mock(\Psr\Http\Message\ResponseInterface::class);
132132
$stream = m::mock(\Psr\Http\Message\StreamInterface::class);
133-
133+
134134
$stream->shouldReceive('__toString')->andReturn(\json_encode([
135135
'access_token' => 'fake_access_token',
136136
'refresh_token' => 'fake_refresh_token',

tests/Providers/AlipayTest.php

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class AlipayTest extends TestCase
1717
{
18-
public function testAlipayProviderHasCorrectRedirectResponse()
18+
public function test_alipay_provider_has_correct_redirect_response()
1919
{
2020
$provider = new Alipay([
2121
'client_id' => 'client_id',
@@ -31,7 +31,7 @@ public function testAlipayProviderHasCorrectRedirectResponse()
3131
$this->assertStringContainsString('scope=auth_user', $response);
3232
}
3333

34-
public function testAlipayProviderSandboxMode()
34+
public function test_alipay_provider_sandbox_mode()
3535
{
3636
$provider = new Alipay([
3737
'client_id' => 'client_id',
@@ -45,7 +45,7 @@ public function testAlipayProviderSandboxMode()
4545
$this->assertStringStartsWith('https://openauth.alipaydev.com/oauth2/publicAppAuthorize.htm', $response);
4646
}
4747

48-
public function testAlipayProviderUrlsAndFields()
48+
public function test_alipay_provider_urls_and_fields()
4949
{
5050
$provider = new Alipay([
5151
'client_id' => 'client_id',
@@ -59,7 +59,7 @@ public function testAlipayProviderUrlsAndFields()
5959
$this->assertSame('https://openapi.alipay.com/gateway.do', $getTokenUrl->invoke($provider));
6060
}
6161

62-
public function testGetPublicFields()
62+
public function test_get_public_fields()
6363
{
6464
$provider = new Alipay([
6565
'client_id' => 'test_app_id',
@@ -84,7 +84,7 @@ public function testGetPublicFields()
8484
$this->assertSame('1.0', $fields['version']);
8585
}
8686

87-
public function testGetCodeFieldsThrowsExceptionWhenNoRedirectUrl()
87+
public function test_get_code_fields_throws_exception_when_no_redirect_url()
8888
{
8989
$provider = new Alipay([
9090
'client_id' => 'client_id',
@@ -99,7 +99,7 @@ public function testGetCodeFieldsThrowsExceptionWhenNoRedirectUrl()
9999
$getCodeFields->invoke($provider);
100100
}
101101

102-
public function testGetCodeFields()
102+
public function test_get_code_fields()
103103
{
104104
$provider = new Alipay([
105105
'app_id' => 'test_app_id',
@@ -119,7 +119,7 @@ public function testGetCodeFields()
119119
$this->assertSame('http://localhost/callback', $fields['redirect_uri']);
120120
}
121121

122-
public function testSignWithSHA256RSAThrowsExceptionWhenNoPrivateKey()
122+
public function test_sign_with_sh_a256_rsa_throws_exception_when_no_private_key()
123123
{
124124
$provider = new Alipay([
125125
'client_id' => 'client_id',
@@ -134,7 +134,7 @@ public function testSignWithSHA256RSAThrowsExceptionWhenNoPrivateKey()
134134
$signWithSHA256RSA->invoke($provider, 'test_content', '');
135135
}
136136

137-
public function testBuildParams()
137+
public function test_build_params()
138138
{
139139
$params = [
140140
'app_id' => 'test_app_id',
@@ -150,7 +150,7 @@ public function testBuildParams()
150150
$this->assertStringContainsString('timestamp=2024-01-01%2012%3A00%3A00', $resultWithUrlencode);
151151
}
152152

153-
public function testTokenFromCodeSuccess()
153+
public function test_token_from_code_success()
154154
{
155155
$provider = new Alipay([
156156
'client_id' => 'client_id',
@@ -163,27 +163,27 @@ public function testTokenFromCodeSuccess()
163163
new Response(200, [], json_encode([
164164
'alipay_system_oauth_token_response' => [
165165
'access_token' => 'token123',
166-
'user_id' => 'user123'
167-
]
168-
]))
166+
'user_id' => 'user123',
167+
],
168+
])),
169169
]);
170170

171171
$handler = HandlerStack::create($mock);
172172
$client = new Client(['handler' => $handler]);
173-
173+
174174
// Use reflection to set the HTTP client
175175
$reflection = new \ReflectionObject($provider);
176176
$httpClientProperty = $reflection->getProperty('httpClient');
177177
$httpClientProperty->setAccessible(true);
178178
$httpClientProperty->setValue($provider, $client);
179179

180180
$token = $provider->tokenFromCode('test_code');
181-
181+
182182
$this->assertArrayHasKey('access_token', $token);
183183
$this->assertSame('token123', $token['access_token']);
184184
}
185185

186-
public function testThrowsExceptionWhenTokenResponseMissing()
186+
public function test_throws_exception_when_token_response_missing()
187187
{
188188
$provider = new Alipay([
189189
'client_id' => 'client_id',
@@ -194,13 +194,13 @@ public function testThrowsExceptionWhenTokenResponseMissing()
194194
// Mock HTTP response without alipay_system_oauth_token_response
195195
$mock = new MockHandler([
196196
new Response(200, [], json_encode([
197-
'some_other_field' => 'value'
198-
]))
197+
'some_other_field' => 'value',
198+
])),
199199
]);
200200

201201
$handler = HandlerStack::create($mock);
202202
$client = new Client(['handler' => $handler]);
203-
203+
204204
// Use reflection to set the HTTP client
205205
$reflection = new \ReflectionObject($provider);
206206
$httpClientProperty = $reflection->getProperty('httpClient');
@@ -209,11 +209,11 @@ public function testThrowsExceptionWhenTokenResponseMissing()
209209

210210
$this->expectException(AuthorizeFailedException::class);
211211
$this->expectExceptionMessage('Authorization failed: missing alipay_system_oauth_token_response in response');
212-
212+
213213
$provider->tokenFromCode('test_code');
214214
}
215215

216-
public function testThrowsExceptionWhenErrorResponse()
216+
public function test_throws_exception_when_error_response()
217217
{
218218
$provider = new Alipay([
219219
'client_id' => 'client_id',
@@ -226,14 +226,14 @@ public function testThrowsExceptionWhenErrorResponse()
226226
new Response(200, [], json_encode([
227227
'error_response' => [
228228
'code' => '20001',
229-
'msg' => 'Invalid parameters'
230-
]
231-
]))
229+
'msg' => 'Invalid parameters',
230+
],
231+
])),
232232
]);
233233

234234
$handler = HandlerStack::create($mock);
235235
$client = new Client(['handler' => $handler]);
236-
236+
237237
// Use reflection to set the HTTP client
238238
$reflection = new \ReflectionObject($provider);
239239
$httpClientProperty = $reflection->getProperty('httpClient');
@@ -245,7 +245,7 @@ public function testThrowsExceptionWhenErrorResponse()
245245
$provider->tokenFromCode('test_code');
246246
}
247247

248-
public function testGetUserByTokenSuccess()
248+
public function test_get_user_by_token_success()
249249
{
250250
$provider = new Alipay([
251251
'client_id' => 'client_id',
@@ -258,14 +258,14 @@ public function testGetUserByTokenSuccess()
258258
new Response(200, [], json_encode([
259259
'alipay_user_info_share_response' => [
260260
'user_id' => 'user123',
261-
'nick_name' => 'Test User'
262-
]
263-
]))
261+
'nick_name' => 'Test User',
262+
],
263+
])),
264264
]);
265265

266266
$handler = HandlerStack::create($mock);
267267
$client = new Client(['handler' => $handler]);
268-
268+
269269
// Use reflection to set the HTTP client
270270
$reflection = new \ReflectionObject($provider);
271271
$httpClientProperty = $reflection->getProperty('httpClient');
@@ -282,7 +282,7 @@ public function testGetUserByTokenSuccess()
282282
$this->assertSame('Test User', $result['nick_name']);
283283
}
284284

285-
public function testGetUserByTokenThrowsExceptionWhenErrorResponse()
285+
public function test_get_user_by_token_throws_exception_when_error_response()
286286
{
287287
$provider = new Alipay([
288288
'client_id' => 'client_id',
@@ -295,14 +295,14 @@ public function testGetUserByTokenThrowsExceptionWhenErrorResponse()
295295
new Response(200, [], json_encode([
296296
'error_response' => [
297297
'code' => '20001',
298-
'msg' => 'Invalid token'
299-
]
300-
]))
298+
'msg' => 'Invalid token',
299+
],
300+
])),
301301
]);
302302

303303
$handler = HandlerStack::create($mock);
304304
$client = new Client(['handler' => $handler]);
305-
305+
306306
// Use reflection to set the HTTP client
307307
$reflection = new \ReflectionObject($provider);
308308
$httpClientProperty = $reflection->getProperty('httpClient');
@@ -316,7 +316,7 @@ public function testGetUserByTokenThrowsExceptionWhenErrorResponse()
316316
$getUserByToken->invoke($provider, 'test_token');
317317
}
318318

319-
public function testMapUserToObject()
319+
public function test_map_user_to_object()
320320
{
321321
$provider = new Alipay([
322322
'client_id' => 'client_id',
@@ -341,4 +341,4 @@ public function testMapUserToObject()
341341
$this->assertSame('http://avatar.url', $result->getAvatar());
342342
$this->assertSame('[email protected]', $result->getEmail());
343343
}
344-
}
344+
}

0 commit comments

Comments
 (0)