@@ -36,12 +36,12 @@ class OAuthStorageTest extends \PHPUnit_Framework_TestCase
36
36
37
37
public function setUp ()
38
38
{
39
- $ this ->clientManager = $ this ->getMock ('FOS\OAuthServerBundle\Model\ClientManagerInterface ' );
40
- $ this ->accessTokenManager = $ this ->getMock ('FOS\OAuthServerBundle\Model\AccessTokenManagerInterface ' );
41
- $ this ->refreshTokenManager = $ this ->getMock ('FOS\OAuthServerBundle\Model\RefreshTokenManagerInterface ' );
42
- $ this ->authCodeManager = $ this ->getMock ('FOS\OAuthServerBundle\Model\AuthCodeManagerInterface ' );
43
- $ this ->userProvider = $ this ->getMock ('Symfony\Component\Security\Core\User\UserProviderInterface ' );
44
- $ this ->encoderFactory = $ this ->getMock ('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface ' );
39
+ $ this ->clientManager = $ this ->createMock ('FOS\OAuthServerBundle\Model\ClientManagerInterface ' );
40
+ $ this ->accessTokenManager = $ this ->createMock ('FOS\OAuthServerBundle\Model\AccessTokenManagerInterface ' );
41
+ $ this ->refreshTokenManager = $ this ->createMock ('FOS\OAuthServerBundle\Model\RefreshTokenManagerInterface ' );
42
+ $ this ->authCodeManager = $ this ->createMock ('FOS\OAuthServerBundle\Model\AuthCodeManagerInterface ' );
43
+ $ this ->userProvider = $ this ->createMock ('Symfony\Component\Security\Core\User\UserProviderInterface ' );
44
+ $ this ->encoderFactory = $ this ->createMock ('Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface ' );
45
45
46
46
$ this ->storage = new OAuthStorage ($ this ->clientManager , $ this ->accessTokenManager , $ this ->refreshTokenManager , $ this ->authCodeManager , $ this ->userProvider , $ this ->encoderFactory );
47
47
}
@@ -72,9 +72,9 @@ public function testGetClientReturnsNullIfNotExists()
72
72
73
73
public function testCheckClientCredentialsThrowsIfInvalidClientClass ()
74
74
{
75
- $ client = $ this ->getMock ('OAuth2\Model\IOAuth2Client ' );
75
+ $ client = $ this ->createMock ('OAuth2\Model\IOAuth2Client ' );
76
76
77
- $ this ->setExpectedException ('InvalidArgumentException ' );
77
+ $ this ->expectException ('InvalidArgumentException ' );
78
78
$ this ->storage ->checkClientCredentials ($ client , 'dummy ' );
79
79
}
80
80
@@ -120,9 +120,9 @@ public function testGetAccessTokenReturnsNullIfNotExists()
120
120
121
121
public function testCreateAccessTokenThrowsOnInvalidClientClass ()
122
122
{
123
- $ client = $ this ->getMock ('OAuth2\Model\IOAuth2Client ' );
123
+ $ client = $ this ->createMock ('OAuth2\Model\IOAuth2Client ' );
124
124
125
- $ this ->setExpectedException ('InvalidArgumentException ' );
125
+ $ this ->expectException ('InvalidArgumentException ' );
126
126
$ this ->storage ->createAccessToken ('foo ' , $ client , new User (42 ), 1 , 'foo bar ' );
127
127
}
128
128
@@ -201,9 +201,9 @@ public function testGetRefreshTokenReturnsNullIfNotExists()
201
201
202
202
public function testCreateRefreshTokenThrowsOnInvalidClientClass ()
203
203
{
204
- $ client = $ this ->getMock ('OAuth2\Model\IOAuth2Client ' );
204
+ $ client = $ this ->createMock ('OAuth2\Model\IOAuth2Client ' );
205
205
206
- $ this ->setExpectedException ('InvalidArgumentException ' );
206
+ $ this ->expectException ('InvalidArgumentException ' );
207
207
$ this ->storage ->createRefreshToken ('foo ' , $ client , 42 , 1 , 'foo bar ' );
208
208
}
209
209
@@ -260,9 +260,9 @@ public function testCreateRefreshTokenWithoutUser()
260
260
261
261
public function testCheckRestrictedGrantTypeThrowsOnInvalidClientClass ()
262
262
{
263
- $ client = $ this ->getMock ('OAuth2\Model\IOAuth2Client ' );
263
+ $ client = $ this ->createMock ('OAuth2\Model\IOAuth2Client ' );
264
264
265
- $ this ->setExpectedException ('InvalidArgumentException ' );
265
+ $ this ->expectException ('InvalidArgumentException ' );
266
266
267
267
$ this ->storage ->checkRestrictedGrantType ($ client , 'foo ' );
268
268
}
@@ -279,9 +279,9 @@ public function testCheckRestrictedGrantType()
279
279
280
280
public function testCheckUserCredentialsThrowsOnInvalidClientClass ()
281
281
{
282
- $ client = $ this ->getMock ('OAuth2\Model\IOAuth2Client ' );
282
+ $ client = $ this ->createMock ('OAuth2\Model\IOAuth2Client ' );
283
283
284
- $ this ->setExpectedException ('InvalidArgumentException ' );
284
+ $ this ->expectException ('InvalidArgumentException ' );
285
285
286
286
$ this ->storage ->checkUserCredentials ($ client , 'Joe ' , 'baz ' );
287
287
}
@@ -298,13 +298,13 @@ public function testCheckUserCredentialsCatchesAuthenticationExceptions()
298
298
public function testCheckUserCredentialsReturnsTrueOnValidCredentials ()
299
299
{
300
300
$ client = new Client ();
301
- $ user = $ this ->getMock ('Symfony\Component\Security\Core\User\UserInterface ' );
301
+ $ user = $ this ->createMock ('Symfony\Component\Security\Core\User\UserInterface ' );
302
302
$ user ->expects ($ this ->once ())
303
303
->method ('getPassword ' )->with ()->will ($ this ->returnValue ('foo ' ));
304
304
$ user ->expects ($ this ->once ())
305
305
->method ('getSalt ' )->with ()->will ($ this ->returnValue ('bar ' ));
306
306
307
- $ encoder = $ this ->getMock ('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface ' );
307
+ $ encoder = $ this ->createMock ('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface ' );
308
308
$ encoder ->expects ($ this ->once ())
309
309
->method ('isPasswordValid ' )
310
310
->with ('foo ' , 'baz ' , 'bar ' )
@@ -328,13 +328,13 @@ public function testCheckUserCredentialsReturnsTrueOnValidCredentials()
328
328
public function testCheckUserCredentialsReturnsFalseOnInvalidCredentials ()
329
329
{
330
330
$ client = new Client ();
331
- $ user = $ this ->getMock ('Symfony\Component\Security\Core\User\UserInterface ' );
331
+ $ user = $ this ->createMock ('Symfony\Component\Security\Core\User\UserInterface ' );
332
332
$ user ->expects ($ this ->once ())
333
333
->method ('getPassword ' )->with ()->will ($ this ->returnValue ('foo ' ));
334
334
$ user ->expects ($ this ->once ())
335
335
->method ('getSalt ' )->with ()->will ($ this ->returnValue ('bar ' ));
336
336
337
- $ encoder = $ this ->getMock ('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface ' );
337
+ $ encoder = $ this ->createMock ('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface ' );
338
338
$ encoder ->expects ($ this ->once ())
339
339
->method ('isPasswordValid ' )
340
340
->with ('foo ' , 'baz ' , 'bar ' )
@@ -367,9 +367,9 @@ public function testCheckUserCredentialsReturnsFalseIfUserNotExist()
367
367
368
368
public function testCreateAuthCodeThrowsOnInvalidClientClass ()
369
369
{
370
- $ client = $ this ->getMock ('OAuth2\Model\IOAuth2Client ' );
370
+ $ client = $ this ->createMock ('OAuth2\Model\IOAuth2Client ' );
371
371
372
- $ this ->setExpectedException ('InvalidArgumentException ' );
372
+ $ this ->expectException ('InvalidArgumentException ' );
373
373
$ this ->storage ->createAuthCode ('foo ' , $ client , 42 , 'http://www.example.com/ ' , 1 , 'foo bar ' );
374
374
}
375
375
@@ -426,15 +426,15 @@ public function testGetAuthCodeReturnsNullIfNotExists()
426
426
427
427
public function testValidGrantExtension ()
428
428
{
429
- $ grantExtension = $ this ->getMock ('FOS\OAuthServerBundle\Storage\GrantExtensionInterface ' );
429
+ $ grantExtension = $ this ->createMock ('FOS\OAuthServerBundle\Storage\GrantExtensionInterface ' );
430
430
$ grantExtension
431
431
->expects ($ this ->once ())
432
432
->method ('checkGrantExtension ' )
433
433
->will ($ this ->returnValue (true ))
434
434
;
435
435
$ this ->storage ->setGrantExtension ('https://friendsofsymfony.com/grants/foo ' , $ grantExtension );
436
436
437
- $ client = $ this ->getMock ('OAuth2\Model\IOAuth2Client ' );
437
+ $ client = $ this ->createMock ('OAuth2\Model\IOAuth2Client ' );
438
438
$ this ->assertTrue ($ this ->storage ->checkGrantExtension ($ client , 'https://friendsofsymfony.com/grants/foo ' , array (), array ()));
439
439
}
440
440
@@ -443,14 +443,14 @@ public function testValidGrantExtension()
443
443
*/
444
444
public function testInvalidGrantExtension ()
445
445
{
446
- $ client = $ this ->getMock ('OAuth2\Model\IOAuth2Client ' );
446
+ $ client = $ this ->createMock ('OAuth2\Model\IOAuth2Client ' );
447
447
$ this ->storage ->checkGrantExtension ($ client , 'https://friendsofsymfony.com/grants/bar ' , array (), array ());
448
448
}
449
449
450
450
public function testDoubleSetGrantExtension ()
451
451
{
452
- $ grantExtension = $ this ->getMock ('FOS\OAuthServerBundle\Storage\GrantExtensionInterface ' );
453
- $ grantExtension2 = $ this ->getMock ('FOS\OAuthServerBundle\Storage\GrantExtensionInterface ' );
452
+ $ grantExtension = $ this ->createMock ('FOS\OAuthServerBundle\Storage\GrantExtensionInterface ' );
453
+ $ grantExtension2 = $ this ->createMock ('FOS\OAuthServerBundle\Storage\GrantExtensionInterface ' );
454
454
$ this ->storage ->setGrantExtension ($ uri = 'https://friendsofsymfony.com/grants/foo ' , $ grantExtension );
455
455
$ this ->storage ->setGrantExtension ($ uri , $ grantExtension2 );
456
456
@@ -464,7 +464,7 @@ public function testDoubleSetGrantExtension()
464
464
465
465
public function testMarkAuthCodeAsUsedIfAuthCodeFound ()
466
466
{
467
- $ authCode = $ this ->getMock ('FOS\OAuthServerBundle\Model\AuthCodeInterface ' );
467
+ $ authCode = $ this ->createMock ('FOS\OAuthServerBundle\Model\AuthCodeInterface ' );
468
468
469
469
$ this ->authCodeManager ->expects ($ this ->atLeastOnce ())
470
470
->method ('findAuthCodeByToken ' )
0 commit comments