1414/**
1515 * OAuth2 test case.
1616 */
17- class OAuth2Test extends PHPUnit_Framework_TestCase
17+ class OAuth2Test extends \ PHPUnit \ Framework \TestCase
1818{
1919 /**
2020 * @var OAuth2
@@ -32,11 +32,11 @@ class OAuth2Test extends PHPUnit_Framework_TestCase
3232 */
3333 public function testVerifyAccessTokenWithNoParam ()
3434 {
35- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
35+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
3636 $ this ->fixture = new OAuth2 ($ mockStorage );
3737
3838 $ scope = null ;
39- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
39+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
4040 $ this ->fixture ->verifyAccessToken ('' , $ scope );
4141 }
4242
@@ -46,15 +46,15 @@ public function testVerifyAccessTokenWithNoParam()
4646 public function testVerifyAccessTokenInvalidToken ()
4747 {
4848 // 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 ' );
5050 $ mockStorage ->expects ($ this ->once ())
5151 ->method ('getAccessToken ' )
5252 ->will ($ this ->returnValue (false ));
5353
5454 $ this ->fixture = new OAuth2 ($ mockStorage );
5555
5656 $ scope = null ;
57- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
57+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
5858 $ this ->fixture ->verifyAccessToken ($ this ->tokenId , $ scope );
5959 }
6060
@@ -66,15 +66,15 @@ public function testVerifyAccessTokenInvalidToken()
6666 public function testVerifyAccessTokenMalformedToken (IOAuth2AccessToken $ token )
6767 {
6868 // 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 ' );
7070 $ mockStorage ->expects ($ this ->once ())
7171 ->method ('getAccessToken ' )
7272 ->will ($ this ->returnValue ($ token ));
7373
7474 $ this ->fixture = new OAuth2 ($ mockStorage );
7575
7676 $ scope = null ;
77- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
77+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
7878 $ this ->fixture ->verifyAccessToken ($ this ->tokenId , $ scope );
7979 }
8080
@@ -86,7 +86,7 @@ public function testVerifyAccessTokenMalformedToken(IOAuth2AccessToken $token)
8686 public function testVerifyAccessTokenCheckExpiry (IOAuth2AccessToken $ token , $ expectedToPass )
8787 {
8888 // 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 ' );
9090 $ mockStorage ->expects ($ this ->once ())
9191 ->method ('getAccessToken ' )
9292 ->will ($ this ->returnValue ($ token ));
@@ -101,7 +101,7 @@ public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $exp
101101 $ this ->assertNotEmpty ($ actual , "verifyAccessToken() was expected to PASS, but it failed " );
102102 $ this ->assertInstanceOf ('OAuth2\Model\IOAuth2AccessToken ' , $ actual );
103103 } else {
104- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
104+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
105105 $ this ->fixture ->verifyAccessToken ($ this ->tokenId , $ scope );
106106 }
107107 }
@@ -114,7 +114,7 @@ public function testVerifyAccessTokenCheckExpiry(IOAuth2AccessToken $token, $exp
114114 public function testVerifyAccessTokenCheckScope ($ scopeRequired , IOAuth2AccessToken $ token , $ expectedToPass )
115115 {
116116 // 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 ' );
118118 $ mockStorage ->expects ($ this ->once ())
119119 ->method ('getAccessToken ' )
120120 ->will ($ this ->returnValue ($ token ));
@@ -127,7 +127,7 @@ public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessTok
127127 $ this ->assertNotEmpty ($ actual , "verifyAccessToken() was expected to PASS, but it failed " );
128128 $ this ->assertInstanceOf ('OAuth2\Model\IOAuth2AccessToken ' , $ actual );
129129 } else {
130- $ this ->setExpectedException ('OAuth2\OAuth2AuthenticateException ' );
130+ $ this ->expectException ('OAuth2\OAuth2AuthenticateException ' );
131131 $ this ->fixture ->verifyAccessToken ($ this ->tokenId , $ scopeRequired );
132132 }
133133 }
@@ -139,10 +139,10 @@ public function testVerifyAccessTokenCheckScope($scopeRequired, IOAuth2AccessTok
139139 */
140140 public function testGrantAccessTokenMissingData ($ request )
141141 {
142- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
142+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
143143 $ this ->fixture = new OAuth2 ($ mockStorage );
144144
145- $ this ->setExpectedException ('OAuth2\OAuth2ServerException ' );
145+ $ this ->expectException ('OAuth2\OAuth2ServerException ' );
146146 $ this ->fixture ->grantAccessToken ($ request );
147147 }
148148
@@ -153,7 +153,7 @@ public function testGrantAccessTokenMissingData($request)
153153 */
154154 public function testGrantAccessTokenCheckClientCredentials ()
155155 {
156- $ mockStorage = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
156+ $ mockStorage = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
157157 $ mockStorage ->expects ($ this ->any ())
158158 ->method ('getClient ' )
159159 ->will ($ this ->returnValue (new OAuth2Client ('dev-abc ' )));
@@ -384,6 +384,7 @@ public function testGrantAccessTokenWithSameGrantAuthCode()
384384 /**
385385 * Tests OAuth2->grantAccessToken() with implicit
386386 *
387+ * @doesNotPerformAssertions
387388 */
388389 public function testGrantAccessTokenWithGrantImplicit ()
389390 {
@@ -591,6 +592,7 @@ public function testGrantAccessTokenWithGrantUserWithNewScopeThrowsError()
591592 /**
592593 * Tests OAuth2->grantAccessToken() with client credentials
593594 *
595+ * @doesNotPerformAssertions
594596 */
595597 public function testGrantAccessTokenWithGrantClient ()
596598 {
@@ -602,6 +604,7 @@ public function testGrantAccessTokenWithGrantClient()
602604 /**
603605 * Tests OAuth2->grantAccessToken() with refresh token
604606 *
607+ * @doesNotPerformAssertions
605608 */
606609 public function testGrantAccessTokenWithGrantRefresh ()
607610 {
@@ -727,6 +730,7 @@ public function testGrantAccessTokenWithGrantExtensionJwtBearer()
727730
728731 /**
729732 * Tests OAuth2->getAuthorizeParams()
733+ * @doesNotPerformAssertions
730734 */
731735 public function testGetAuthorizeParams ()
732736 {
@@ -1077,7 +1081,7 @@ public function testFinishClientAuthorizationThrowsErrorIfUnauthorized()
10771081 */
10781082 public function testGetBearerToken (Request $ request , $ token , $ remove = false , $ exception = null , $ exceptionMessage = null , $ headers = null , $ body = null )
10791083 {
1080- $ mock = $ this ->getMockBuilder ('OAuth2\IOAuth2Storage ' )-> getMock ( );
1084+ $ mock = $ this ->createMock ('OAuth2\IOAuth2Storage ' );
10811085 $ oauth2 = new OAuth2 ($ mock );
10821086
10831087 try {
@@ -1225,7 +1229,7 @@ public function getTestGetBearerTokenData()
12251229 */
12261230 protected function createBaseMock ($ interfaceName )
12271231 {
1228- $ mockStorage = $ this ->getMockBuilder ($ interfaceName)-> getMock ( );
1232+ $ mockStorage = $ this ->createMock ($ interfaceName );
12291233 $ mockStorage ->expects ($ this ->any ())
12301234 ->method ('checkClientCredentials ' )
12311235 ->will ($ this ->returnValue (true )); // Always return true for any combination of user/pass
0 commit comments