2
2
3
3
namespace League \OAuth2 \Client \Test \Provider ;
4
4
5
+ use UnexpectedValueException ;
5
6
use Eloquent \Liberator \Liberator ;
6
7
use Eloquent \Phony \Phpunit \Phony ;
7
8
use GuzzleHttp \Exception \BadResponseException ;
10
11
use League \OAuth2 \Client \Test \Provider \Fake as MockProvider ;
11
12
use League \OAuth2 \Client \Grant \AbstractGrant ;
12
13
use League \OAuth2 \Client \Grant \GrantFactory ;
14
+ use League \OAuth2 \Client \Grant \Exception \InvalidGrantException ;
13
15
use League \OAuth2 \Client \Token \AccessToken ;
14
16
use League \OAuth2 \Client \Tool \RequestFactory ;
15
17
use League \OAuth2 \Client \Provider \Exception \IdentityProviderException ;
@@ -34,19 +36,15 @@ protected function setUp()
34
36
]);
35
37
}
36
38
37
- /**
38
- * @expectedException League\OAuth2\Client\Grant\Exception\InvalidGrantException
39
- */
40
39
public function testInvalidGrantString ()
41
40
{
41
+ $ this ->expectException (InvalidGrantException::class);
42
42
$ this ->provider ->getAccessToken ('invalid_grant ' , ['invalid_parameter ' => 'none ' ]);
43
43
}
44
44
45
- /**
46
- * @expectedException League\OAuth2\Client\Grant\Exception\InvalidGrantException
47
- */
48
45
public function testInvalidGrantObject ()
49
46
{
47
+ $ this ->expectException (InvalidGrantException::class);
50
48
$ grant = new \StdClass ();
51
49
$ this ->provider ->getAccessToken ($ grant , ['invalid_parameter ' => 'none ' ]);
52
50
}
@@ -397,11 +395,9 @@ public function testErrorResponsesCanBeCustomizedAtTheProvider()
397
395
);
398
396
}
399
397
400
- /**
401
- * @expectedException \League\OAuth2\Client\Provider\Exception\IdentityProviderException
402
- */
403
398
public function testClientErrorTriggersProviderException ()
404
399
{
400
+ $ this ->expectException (IdentityProviderException::class);
405
401
$ provider = new MockProvider ([
406
402
'clientId ' => 'mock_client_id ' ,
407
403
'clientSecret ' => 'mock_secret ' ,
@@ -597,19 +593,15 @@ public function testParseResponse($body, $type, $parsed, $statusCode = 200)
597
593
$ this ->assertEquals ($ parsed , $ result );
598
594
}
599
595
600
- /**
601
- * @expectedException UnexpectedValueException
602
- */
603
596
public function testParseResponseJsonFailure ()
604
597
{
598
+ $ this ->expectException (UnexpectedValueException::class);
605
599
$ this ->testParseResponse ('{a: 1} ' , 'application/json ' , null );
606
600
}
607
601
608
- /**
609
- * @expectedException UnexpectedValueException
610
- */
611
602
public function testParseResponseNonJsonFailure ()
612
603
{
604
+ $ this ->expectException (UnexpectedValueException::class);
613
605
$ this ->testParseResponse ('<xml></xml> ' , 'application/xml ' , null , 500 );
614
606
}
615
607
0 commit comments