diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 1fb4480..fc3b73f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -2,4 +2,8 @@ This project welcomes contributions. +New features should be covered by unit tests and linting. +Including tests increases your chances of getting the PR accepted. +I might merge even if tests are missing, but it will likely take more time. +Run `composer check` before submitting a pull request and fix what you can there to ensure that the code is up to the standard. diff --git a/src/AccessToken.php b/src/AccessToken.php index 572b667..78637b2 100644 --- a/src/AccessToken.php +++ b/src/AccessToken.php @@ -44,14 +44,12 @@ public function getExpiresIn(): int public function getHttpClient(PendingRequest $httpClient): PendingRequest { - return match ($this->tokenType) { self::TYPE_BEARER => $httpClient->withToken($this->accessToken), self::TYPE_QUERY => $httpClient->withQueryParameters([$this->tokenName => $this->accessToken]), self::TYPE_CUSTOM => $this->resolveCustomAuth($httpClient), default => throw new InvalidArgumentException('Invalid auth type') }; - } protected function resolveCustomAuth(PendingRequest $httpClient): PendingRequest diff --git a/tests/TestCase.php b/tests/TestCase.php index ed329e9..79118f5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -16,7 +16,6 @@ protected function setUp(): void Http::fake( static function (Request $request) { - if ($request->url() === 'https://example.com/oauth/token') { if ($request->token = 'my_refresh_token') { return Http::response([ diff --git a/tests/Unit/RefreshTokenTest.php b/tests/Unit/RefreshTokenTest.php index 87723a6..701bdde 100644 --- a/tests/Unit/RefreshTokenTest.php +++ b/tests/Unit/RefreshTokenTest.php @@ -9,7 +9,6 @@ use Pelmered\LaravelHttpOAuthHelper\RefreshToken; describe('Refresh Token Class', function () { - test('refresh token basic', function () { Cache::clear(); $accessToken = app(RefreshToken::class)( @@ -139,7 +138,6 @@ }); test('refresh token with expiry callback', function () { - $accessToken = app(RefreshToken::class)( 'https://example.com/oauth/token', new Credentials([ @@ -158,7 +156,6 @@ Http::assertSent(static function (Request $request) { return $request->url() === 'https://example.com/oauth/token' && $request['grant_type'] === 'client_credentials' && $request['scope'] === 'scope1 scope2'; }); - }); test('get access token from custom key', function () { @@ -213,5 +210,4 @@ ] ); }); - })->done(assignee: 'pelmered'); diff --git a/tests/Unit/TokenStoreTest.php b/tests/Unit/TokenStoreTest.php index f4dd01b..1162587 100644 --- a/tests/Unit/TokenStoreTest.php +++ b/tests/Unit/TokenStoreTest.php @@ -8,7 +8,6 @@ use Pelmered\LaravelHttpOAuthHelper\TokenStore; it('reads and stores a token in cache', function () { - Cache::clear(); Cache::spy();