Skip to content

Commit

Permalink
Improve AbstractProvider code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioheleno committed Dec 11, 2024
1 parent 19d2064 commit 7f85a84
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
33 changes: 33 additions & 0 deletions test/src/Provider/AbstractProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit 7f85a84

Please sign in to comment.