Skip to content

Commit 5ca87bd

Browse files
committed
Improve AbstractProvider code coverage
1 parent 2de9e08 commit 5ca87bd

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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)