Skip to content

Commit 63c505a

Browse files
committed
Update test cases expecting exceptions
1 parent f818b08 commit 63c505a

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

test/src/Provider/AbstractProviderTest.php

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

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

5+
use UnexpectedValueException;
56
use Eloquent\Liberator\Liberator;
67
use Eloquent\Phony\Phpunit\Phony;
78
use GuzzleHttp\Exception\BadResponseException;
@@ -10,6 +11,7 @@
1011
use League\OAuth2\Client\Test\Provider\Fake as MockProvider;
1112
use League\OAuth2\Client\Grant\AbstractGrant;
1213
use League\OAuth2\Client\Grant\GrantFactory;
14+
use League\OAuth2\Client\Grant\Exception\InvalidGrantException;
1315
use League\OAuth2\Client\Token\AccessToken;
1416
use League\OAuth2\Client\Tool\RequestFactory;
1517
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
@@ -34,19 +36,15 @@ protected function setUp()
3436
]);
3537
}
3638

37-
/**
38-
* @expectedException League\OAuth2\Client\Grant\Exception\InvalidGrantException
39-
*/
4039
public function testInvalidGrantString()
4140
{
41+
$this->expectException(InvalidGrantException::class);
4242
$this->provider->getAccessToken('invalid_grant', ['invalid_parameter' => 'none']);
4343
}
4444

45-
/**
46-
* @expectedException League\OAuth2\Client\Grant\Exception\InvalidGrantException
47-
*/
4845
public function testInvalidGrantObject()
4946
{
47+
$this->expectException(InvalidGrantException::class);
5048
$grant = new \StdClass();
5149
$this->provider->getAccessToken($grant, ['invalid_parameter' => 'none']);
5250
}
@@ -397,11 +395,9 @@ public function testErrorResponsesCanBeCustomizedAtTheProvider()
397395
);
398396
}
399397

400-
/**
401-
* @expectedException \League\OAuth2\Client\Provider\Exception\IdentityProviderException
402-
*/
403398
public function testClientErrorTriggersProviderException()
404399
{
400+
$this->expectException(IdentityProviderException::class);
405401
$provider = new MockProvider([
406402
'clientId' => 'mock_client_id',
407403
'clientSecret' => 'mock_secret',
@@ -597,19 +593,15 @@ public function testParseResponse($body, $type, $parsed, $statusCode = 200)
597593
$this->assertEquals($parsed, $result);
598594
}
599595

600-
/**
601-
* @expectedException UnexpectedValueException
602-
*/
603596
public function testParseResponseJsonFailure()
604597
{
598+
$this->expectException(UnexpectedValueException::class);
605599
$this->testParseResponse('{a: 1}', 'application/json', null);
606600
}
607601

608-
/**
609-
* @expectedException UnexpectedValueException
610-
*/
611602
public function testParseResponseNonJsonFailure()
612603
{
604+
$this->expectException(UnexpectedValueException::class);
613605
$this->testParseResponse('<xml></xml>', 'application/xml', null, 500);
614606
}
615607

0 commit comments

Comments
 (0)