14
14
/**
15
15
* OAuth2 test case.
16
16
*/
17
- class OAuth2Test extends PHPUnit_Framework_TestCase
17
+ class OAuth2Test extends \ PHPUnit \ Framework \TestCase
18
18
{
19
19
/**
20
20
* @var OAuth2
@@ -32,11 +32,11 @@ class OAuth2Test extends PHPUnit_Framework_TestCase
32
32
*/
33
33
public function testVerifyAccessTokenWithNoParam ()
34
34
{
35
- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
35
+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
36
36
$ this ->fixture = new OAuth2 ($ mockStorage );
37
37
38
38
$ scope = null ;
39
- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
39
+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
40
40
$ this ->fixture ->verifyAccessToken ('' , $ scope );
41
41
}
42
42
@@ -46,15 +46,15 @@ public function testVerifyAccessTokenWithNoParam()
46
46
public function testVerifyAccessTokenInvalidToken ()
47
47
{
48
48
// Set up the mock storage to say this token does not exist
49
- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
49
+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
50
50
$ mockStorage ->expects ($ this ->once ())
51
51
->method ('getAccessToken ' )
52
52
->will ($ this ->returnValue (false ));
53
53
54
54
$ this ->fixture = new OAuth2 ($ mockStorage );
55
55
56
56
$ scope = null ;
57
- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
57
+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
58
58
$ this ->fixture ->verifyAccessToken ($ this ->tokenId , $ scope );
59
59
}
60
60
@@ -66,15 +66,15 @@ public function testVerifyAccessTokenInvalidToken()
66
66
public function testVerifyAccessTokenMalformedToken (IOAuth2AccessToken $ token )
67
67
{
68
68
// Set up the mock storage to say this token does not exist
69
- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
69
+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
70
70
$ mockStorage ->expects ($ this ->once ())
71
71
->method ('getAccessToken ' )
72
72
->will ($ this ->returnValue ($ token ));
73
73
74
74
$ this ->fixture = new OAuth2 ($ mockStorage );
75
75
76
76
$ scope = null ;
77
- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
77
+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
78
78
$ this ->fixture ->verifyAccessToken ($ this ->tokenId , $ scope );
79
79
}
80
80
@@ -86,7 +86,7 @@ public function testVerifyAccessTokenMalformedToken(IOAuth2AccessToken $token)
86
86
public function testVerifyAccessTokenCheckExpiry (IOAuth2AccessToken $ token , $ expectedToPass )
87
87
{
88
88
// Set up the mock storage to say this token does not exist
89
- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
89
+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
90
90
$ mockStorage ->expects ($ this ->once ())
91
91
->method ('getAccessToken ' )
92
92
->will ($ this ->returnValue ($ token ));
@@ -101,7 +101,7 @@ public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $exp
101
101
$ this ->assertNotEmpty ($ actual , "verifyAccessToken() was expected to PASS, but it failed " );
102
102
$ this ->assertInstanceOf ('OAuth2\Model\IOAuth2AccessToken ' , $ actual );
103
103
} else {
104
- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
104
+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
105
105
$ this ->fixture ->verifyAccessToken ($ this ->tokenId , $ scope );
106
106
}
107
107
}
@@ -114,7 +114,7 @@ public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $exp
114
114
public function testVerifyAccessTokenCheckScope ($ scopeRequired , IOAuth2AccessToken $ token , $ expectedToPass )
115
115
{
116
116
// Set up the mock storage to say this token does not exist
117
- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
117
+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
118
118
$ mockStorage ->expects ($ this ->once ())
119
119
->method ('getAccessToken ' )
120
120
->will ($ this ->returnValue ($ token ));
@@ -127,7 +127,7 @@ public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessTok
127
127
$ this ->assertNotEmpty ($ actual , "verifyAccessToken() was expected to PASS, but it failed " );
128
128
$ this ->assertInstanceOf ('OAuth2\Model\IOAuth2AccessToken ' , $ actual );
129
129
} else {
130
- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
130
+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
131
131
$ this ->fixture ->verifyAccessToken ($ this ->tokenId , $ scopeRequired );
132
132
}
133
133
}
@@ -139,10 +139,10 @@ public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessTok
139
139
*/
140
140
public function testGrantAccessTokenMissingData ($ request )
141
141
{
142
- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
142
+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
143
143
$ this ->fixture = new OAuth2 ($ mockStorage );
144
144
145
- $ this ->setExpectedException ('OAuth2\OAuth2ServerException ' );
145
+ $ this ->expectException ('OAuth2\OAuth2ServerException ' );
146
146
$ this ->fixture ->grantAccessToken ($ request );
147
147
}
148
148
@@ -153,7 +153,7 @@ public function testGrantAccessTokenMissingData($request)
153
153
*/
154
154
public function testGrantAccessTokenCheckClientCredentials ()
155
155
{
156
- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
156
+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
157
157
$ mockStorage ->expects ($ this ->any ())
158
158
->method ('getClient ' )
159
159
->will ($ this ->returnValue (new OAuth2Client ('dev-abc ' )));
@@ -384,6 +384,7 @@ public function testGrantAccessTokenWithSameGrantAuthCode()
384
384
/**
385
385
* Tests OAuth2->grantAccessToken() with implicit
386
386
*
387
+ * @doesNotPerformAssertions
387
388
*/
388
389
public function testGrantAccessTokenWithGrantImplicit ()
389
390
{
@@ -591,6 +592,7 @@ public function testGrantAccessTokenWithGrantUserWithNewScopeThrowsError()
591
592
/**
592
593
* Tests OAuth2->grantAccessToken() with client credentials
593
594
*
595
+ * @doesNotPerformAssertions
594
596
*/
595
597
public function testGrantAccessTokenWithGrantClient ()
596
598
{
@@ -602,6 +604,7 @@ public function testGrantAccessTokenWithGrantClient()
602
604
/**
603
605
* Tests OAuth2->grantAccessToken() with refresh token
604
606
*
607
+ * @doesNotPerformAssertions
605
608
*/
606
609
public function testGrantAccessTokenWithGrantRefresh ()
607
610
{
@@ -727,6 +730,7 @@ public function testGrantAccessTokenWithGrantExtensionJwtBearer()
727
730
728
731
/**
729
732
* Tests OAuth2->getAuthorizeParams()
733
+ * @doesNotPerformAssertions
730
734
*/
731
735
public function testGetAuthorizeParams ()
732
736
{
@@ -1077,7 +1081,7 @@ public function testFinishClientAuthorizationThrowsErrorIfUnauthorized()
1077
1081
*/
1078
1082
public function testGetBearerToken (Request $ request , $ token , $ remove = false , $ exception = null , $ exceptionMessage = null , $ headers = null , $ body = null )
1079
1083
{
1080
- $ mock = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
1084
+ $ mock = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
1081
1085
$ oauth2 = new OAuth2 ($ mock );
1082
1086
1083
1087
try {
@@ -1225,7 +1229,7 @@ public function getTestGetBearerTokenData()
1225
1229
*/
1226
1230
protected function createBaseMock ($ interfaceName )
1227
1231
{
1228
- $ mockStorage = $ this ->getMockBuilder ($ interfaceName)-> getMock ( );
1232
+ $ mockStorage = $ this ->createMock ($ interfaceName );
1229
1233
$ mockStorage ->expects ($ this ->any ())
1230
1234
->method ('checkClientCredentials ' )
1231
1235
->will ($ this ->returnValue (true )); // Always return true for any combination of user/pass
0 commit comments