From 5ca87bda29a79d1838719e979cf1165a919d4fb0 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 10 Dec 2024 09:21:05 -0300 Subject: [PATCH] Improve AbstractProvider code coverage --- test/src/Provider/AbstractProviderTest.php | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/src/Provider/AbstractProviderTest.php b/test/src/Provider/AbstractProviderTest.php index 2ef60b37..260daf86 100644 --- a/test/src/Provider/AbstractProviderTest.php +++ b/test/src/Provider/AbstractProviderTest.php @@ -2,6 +2,7 @@ namespace League\OAuth2\Client\Test\Provider; +use InvalidArgumentException; use League\OAuth2\Client\OptionProvider\PostAuthOptionProvider; use Mockery; use PHPUnit\Framework\Attributes\DataProvider; @@ -62,6 +63,38 @@ public function testInvalidGrantObject() $this->getMockProvider()->getAccessToken($grant, ['invalid_parameter' => 'none']); } + public function testMissingRequestFactory() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('No request factory set'); + $provider = new Fake(); + } + + public function testMissingStreamFactory() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('No stream factory set'); + $provider = new Fake( + [], + [ + 'requestFactory' => new HttpFactory() + ] + ); + } + + public function testMissingHttpClient() + { + $this->expectException(InvalidArgumentException::class); + $this->expectExceptionMessage('No http client set'); + $provider = new Fake( + [], + [ + 'requestFactory' => new HttpFactory(), + 'streamFactory' => new HttpFactory() + ] + ); + } + public function testAuthorizationUrlStateParam() { $authUrl = $this->getMockProvider()->getAuthorizationUrl([