diff --git a/composer.json b/composer.json index bd60d8e5..534eddd3 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "psr/http-message": "^2.0" }, "require-dev": { - "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5" + "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", "mockery/mockery": "^1.3.5", "php-parallel-lint/php-parallel-lint": "^1.4", "phpunit/phpunit": "^7 || ^8 || ^9 || ^10 || ^11", diff --git a/test/src/Provider/AbstractProviderTest.php b/test/src/Provider/AbstractProviderTest.php index 8d9a55fe..f388c0ec 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([