Skip to content

Commit 7f85a84

Browse files
committed
Improve AbstractProvider code coverage
1 parent 19d2064 commit 7f85a84

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"psr/http-message": "^2.0"
1414
},
1515
"require-dev": {
16-
"guzzlehttp/guzzle": "^6.5.8 || ^7.4.5"
16+
"guzzlehttp/guzzle": "^6.5.8 || ^7.4.5",
1717
"mockery/mockery": "^1.3.5",
1818
"php-parallel-lint/php-parallel-lint": "^1.4",
1919
"phpunit/phpunit": "^7 || ^8 || ^9 || ^10 || ^11",

test/src/Provider/AbstractProviderTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace League\OAuth2\Client\Test\Provider;
44

5+
use InvalidArgumentException;
56
use League\OAuth2\Client\OptionProvider\PostAuthOptionProvider;
67
use Mockery;
78
use PHPUnit\Framework\Attributes\DataProvider;
@@ -62,6 +63,38 @@ public function testInvalidGrantObject()
6263
$this->getMockProvider()->getAccessToken($grant, ['invalid_parameter' => 'none']);
6364
}
6465

66+
public function testMissingRequestFactory()
67+
{
68+
$this->expectException(InvalidArgumentException::class);
69+
$this->expectExceptionMessage('No request factory set');
70+
$provider = new Fake();
71+
}
72+
73+
public function testMissingStreamFactory()
74+
{
75+
$this->expectException(InvalidArgumentException::class);
76+
$this->expectExceptionMessage('No stream factory set');
77+
$provider = new Fake(
78+
[],
79+
[
80+
'requestFactory' => new HttpFactory()
81+
]
82+
);
83+
}
84+
85+
public function testMissingHttpClient()
86+
{
87+
$this->expectException(InvalidArgumentException::class);
88+
$this->expectExceptionMessage('No http client set');
89+
$provider = new Fake(
90+
[],
91+
[
92+
'requestFactory' => new HttpFactory(),
93+
'streamFactory' => new HttpFactory()
94+
]
95+
);
96+
}
97+
6598
public function testAuthorizationUrlStateParam()
6699
{
67100
$authUrl = $this->getMockProvider()->getAuthorizationUrl([

0 commit comments

Comments
 (0)