Skip to content

Commit bfc7f68

Browse files
dnahrebeckidkarlovi
authored andcommitted
fix tests deprecations
1 parent 5f98d29 commit bfc7f68

File tree

9 files changed

+53
-54
lines changed

9 files changed

+53
-54
lines changed

Tests/Command/CleanCommandTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ protected function setUp()
5454
public function testItShouldRemoveExpiredToken($class)
5555
{
5656
$expiredAccessTokens = 5;
57-
$accessTokenManager = $this->getMock($class);
57+
$accessTokenManager = $this->createMock($class);
5858
$accessTokenManager
5959
->expects($this->once())
6060
->method('deleteExpired')
6161
->will($this->returnValue($expiredAccessTokens));
6262

6363
$expiredRefreshTokens = 183;
64-
$refreshTokenManager = $this->getMock($class);
64+
$refreshTokenManager = $this->createMock($class);
6565
$refreshTokenManager
6666
->expects($this->once())
6767
->method('deleteExpired')
6868
->will($this->returnValue($expiredRefreshTokens));
6969

7070
$expiredAuthCodes = 0;
71-
$authCodeManager = $this->getMock($class);
71+
$authCodeManager = $this->createMock($class);
7272
$authCodeManager
7373
->expects($this->once())
7474
->method('deleteExpired')

Tests/Document/TokenManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public function setUp()
2828
}
2929

3030
$this->class = 'FOS\OAuthServerBundle\Document\AccessToken';
31-
$this->repository = $this->getMock('Doctrine\ODM\MongoDB\DocumentRepository', array(), array(), '', false);
32-
$this->dm = $this->getMock('Doctrine\ODM\MongoDB\DocumentManager', array(), array(), '', false);
31+
$this->repository = $this->createMock('Doctrine\ODM\MongoDB\DocumentRepository');
32+
$this->dm = $this->createMock('Doctrine\ODM\MongoDB\DocumentManager');
3333
$this->dm->expects($this->once())
3434
->method('getRepository')
3535
->with($this->class)

Tests/Entity/TokenManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class TokenManagerTest extends \PHPUnit_Framework_TestCase
2727
public function setUp()
2828
{
2929
$this->class = 'FOS\OAuthServerBundle\Entity\AccessToken';
30-
$this->repository = $this->getMock('Doctrine\ORM\EntityRepository', array(), array(), '', false);
31-
$this->em = $this->getMock('Doctrine\ORM\EntityManager', array(), array(), '', false);
30+
$this->repository = $this->createMock('Doctrine\ORM\EntityRepository');
31+
$this->em = $this->createMock('Doctrine\ORM\EntityManager');
3232
$this->em->expects($this->once())
3333
->method('getRepository')
3434
->with($this->class)

Tests/Propel/AuthCodeManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testCreateClass()
4141

4242
public function testUpdate()
4343
{
44-
$authCode = $this->getMock('FOS\OAuthServerBundle\Propel\AuthCode');
44+
$authCode = $this->createMock('FOS\OAuthServerBundle\Propel\AuthCode');
4545
$authCode
4646
->expects($this->once())
4747
->method('save');
@@ -51,7 +51,7 @@ public function testUpdate()
5151

5252
public function testDelete()
5353
{
54-
$authCode = $this->getMock('FOS\OAuthServerBundle\Propel\AuthCode');
54+
$authCode = $this->createMock('FOS\OAuthServerBundle\Propel\AuthCode');
5555
$authCode
5656
->expects($this->once())
5757
->method('delete');

Tests/Propel/ClientManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testCreateClass()
4141

4242
public function testUpdate()
4343
{
44-
$client = $this->getMock('FOS\OAuthServerBundle\Propel\Client');
44+
$client = $this->createMock('FOS\OAuthServerBundle\Propel\Client');
4545
$client
4646
->expects($this->once())
4747
->method('save');
@@ -51,7 +51,7 @@ public function testUpdate()
5151

5252
public function testDelete()
5353
{
54-
$client = $this->getMock('FOS\OAuthServerBundle\Propel\Client');
54+
$client = $this->createMock('FOS\OAuthServerBundle\Propel\Client');
5555
$client
5656
->expects($this->once())
5757
->method('delete');

Tests/Propel/TokenManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testCreateClass()
4242

4343
public function testUpdate()
4444
{
45-
$token = $this->getMock('FOS\OAuthServerBundle\Propel\Token');
45+
$token = $this->createMock('FOS\OAuthServerBundle\Propel\Token');
4646
$token
4747
->expects($this->once())
4848
->method('save');
@@ -52,7 +52,7 @@ public function testUpdate()
5252

5353
public function testDelete()
5454
{
55-
$token = $this->getMock('FOS\OAuthServerBundle\Propel\Token');
55+
$token = $this->createMock('FOS\OAuthServerBundle\Propel\Token');
5656
$token
5757
->expects($this->once())
5858
->method('delete');

Tests/Security/Authentification/Provider/OAuthProviderTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ class OAuthProviderTest extends \PHPUnit_Framework_TestCase
2525

2626
public function setUp()
2727
{
28-
$this->user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
29-
$this->userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
30-
$this->serverService = $this->getMock('OAuth2\OAuth2', array('verifyAccessToken'), array(), '', false);
31-
$this->userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
28+
$this->user = $this->createMock('Symfony\Component\Security\Core\User\UserInterface');
29+
$this->userProvider = $this->createMock('Symfony\Component\Security\Core\User\UserProviderInterface');
30+
$this->serverService = $this->getMockBuilder('OAuth2\OAuth2')
31+
->disableOriginalConstructor()
32+
->setMethods(array('verifyAccessToken'))
33+
->getMock();
34+
$this->userChecker = $this->createMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
3235
$this->provider = new OAuthProvider($this->userProvider, $this->serverService, $this->userChecker);
3336
}
3437

Tests/Security/Firewall/OAuthListenerTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,16 @@ class OAuthListenerTest extends TestCase
2626

2727
public function setUp()
2828
{
29-
$this->serverService = $this
30-
->getMockBuilder('OAuth2\OAuth2')
31-
->disableOriginalConstructor()
32-
->getMock();
29+
$this->serverService = $this->createMock('OAuth2\OAuth2');
3330

3431
$this->authManager = $this
35-
->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
32+
->createMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
3633

3734
if (interface_exists('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')) {
3835
$this->securityContext = $this
39-
->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
36+
->createMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
4037
} else {
41-
$this->securityContext = $this
42-
->getMock('Symfony\Component\Security\Core\SecurityContextInterface');
38+
$this->securityContext = $this->createMock('Symfony\Component\Security\Core\SecurityContextInterface');
4339
}
4440

4541
$this->event = $this
@@ -82,7 +78,7 @@ public function testHandleResponse()
8278
->method('getBearerToken')
8379
->will($this->returnValue('a-token'));
8480

85-
$response = $this->getMock('Symfony\Component\HttpFoundation\Response');
81+
$response = $this->createMock('Symfony\Component\HttpFoundation\Response');
8682

8783
$this->authManager
8884
->expects($this->once())

Tests/Storage/OAuthStorageTest.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ class OAuthStorageTest extends \PHPUnit_Framework_TestCase
3636

3737
public function setUp()
3838
{
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');
4545

4646
$this->storage = new OAuthStorage($this->clientManager, $this->accessTokenManager, $this->refreshTokenManager, $this->authCodeManager, $this->userProvider, $this->encoderFactory);
4747
}
@@ -72,9 +72,9 @@ public function testGetClientReturnsNullIfNotExists()
7272

7373
public function testCheckClientCredentialsThrowsIfInvalidClientClass()
7474
{
75-
$client = $this->getMock('OAuth2\Model\IOAuth2Client');
75+
$client = $this->createMock('OAuth2\Model\IOAuth2Client');
7676

77-
$this->setExpectedException('InvalidArgumentException');
77+
$this->expectException('InvalidArgumentException');
7878
$this->storage->checkClientCredentials($client, 'dummy');
7979
}
8080

@@ -120,9 +120,9 @@ public function testGetAccessTokenReturnsNullIfNotExists()
120120

121121
public function testCreateAccessTokenThrowsOnInvalidClientClass()
122122
{
123-
$client = $this->getMock('OAuth2\Model\IOAuth2Client');
123+
$client = $this->createMock('OAuth2\Model\IOAuth2Client');
124124

125-
$this->setExpectedException('InvalidArgumentException');
125+
$this->expectException('InvalidArgumentException');
126126
$this->storage->createAccessToken('foo', $client, new User(42), 1, 'foo bar');
127127
}
128128

@@ -201,9 +201,9 @@ public function testGetRefreshTokenReturnsNullIfNotExists()
201201

202202
public function testCreateRefreshTokenThrowsOnInvalidClientClass()
203203
{
204-
$client = $this->getMock('OAuth2\Model\IOAuth2Client');
204+
$client = $this->createMock('OAuth2\Model\IOAuth2Client');
205205

206-
$this->setExpectedException('InvalidArgumentException');
206+
$this->expectException('InvalidArgumentException');
207207
$this->storage->createRefreshToken('foo', $client, 42, 1, 'foo bar');
208208
}
209209

@@ -260,9 +260,9 @@ public function testCreateRefreshTokenWithoutUser()
260260

261261
public function testCheckRestrictedGrantTypeThrowsOnInvalidClientClass()
262262
{
263-
$client = $this->getMock('OAuth2\Model\IOAuth2Client');
263+
$client = $this->createMock('OAuth2\Model\IOAuth2Client');
264264

265-
$this->setExpectedException('InvalidArgumentException');
265+
$this->expectException('InvalidArgumentException');
266266

267267
$this->storage->checkRestrictedGrantType($client, 'foo');
268268
}
@@ -279,9 +279,9 @@ public function testCheckRestrictedGrantType()
279279

280280
public function testCheckUserCredentialsThrowsOnInvalidClientClass()
281281
{
282-
$client = $this->getMock('OAuth2\Model\IOAuth2Client');
282+
$client = $this->createMock('OAuth2\Model\IOAuth2Client');
283283

284-
$this->setExpectedException('InvalidArgumentException');
284+
$this->expectException('InvalidArgumentException');
285285

286286
$this->storage->checkUserCredentials($client, 'Joe', 'baz');
287287
}
@@ -298,13 +298,13 @@ public function testCheckUserCredentialsCatchesAuthenticationExceptions()
298298
public function testCheckUserCredentialsReturnsTrueOnValidCredentials()
299299
{
300300
$client = new Client();
301-
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
301+
$user = $this->createMock('Symfony\Component\Security\Core\User\UserInterface');
302302
$user->expects($this->once())
303303
->method('getPassword')->with()->will($this->returnValue('foo'));
304304
$user->expects($this->once())
305305
->method('getSalt')->with()->will($this->returnValue('bar'));
306306

307-
$encoder = $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
307+
$encoder = $this->createMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
308308
$encoder->expects($this->once())
309309
->method('isPasswordValid')
310310
->with('foo', 'baz', 'bar')
@@ -328,13 +328,13 @@ public function testCheckUserCredentialsReturnsTrueOnValidCredentials()
328328
public function testCheckUserCredentialsReturnsFalseOnInvalidCredentials()
329329
{
330330
$client = new Client();
331-
$user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface');
331+
$user = $this->createMock('Symfony\Component\Security\Core\User\UserInterface');
332332
$user->expects($this->once())
333333
->method('getPassword')->with()->will($this->returnValue('foo'));
334334
$user->expects($this->once())
335335
->method('getSalt')->with()->will($this->returnValue('bar'));
336336

337-
$encoder = $this->getMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
337+
$encoder = $this->createMock('Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface');
338338
$encoder->expects($this->once())
339339
->method('isPasswordValid')
340340
->with('foo', 'baz', 'bar')
@@ -367,9 +367,9 @@ public function testCheckUserCredentialsReturnsFalseIfUserNotExist()
367367

368368
public function testCreateAuthCodeThrowsOnInvalidClientClass()
369369
{
370-
$client = $this->getMock('OAuth2\Model\IOAuth2Client');
370+
$client = $this->createMock('OAuth2\Model\IOAuth2Client');
371371

372-
$this->setExpectedException('InvalidArgumentException');
372+
$this->expectException('InvalidArgumentException');
373373
$this->storage->createAuthCode('foo', $client, 42, 'http://www.example.com/', 1, 'foo bar');
374374
}
375375

@@ -426,15 +426,15 @@ public function testGetAuthCodeReturnsNullIfNotExists()
426426

427427
public function testValidGrantExtension()
428428
{
429-
$grantExtension = $this->getMock('FOS\OAuthServerBundle\Storage\GrantExtensionInterface');
429+
$grantExtension = $this->createMock('FOS\OAuthServerBundle\Storage\GrantExtensionInterface');
430430
$grantExtension
431431
->expects($this->once())
432432
->method('checkGrantExtension')
433433
->will($this->returnValue(true))
434434
;
435435
$this->storage->setGrantExtension('https://friendsofsymfony.com/grants/foo', $grantExtension);
436436

437-
$client = $this->getMock('OAuth2\Model\IOAuth2Client');
437+
$client = $this->createMock('OAuth2\Model\IOAuth2Client');
438438
$this->assertTrue($this->storage->checkGrantExtension($client, 'https://friendsofsymfony.com/grants/foo', array(), array()));
439439
}
440440

@@ -443,14 +443,14 @@ public function testValidGrantExtension()
443443
*/
444444
public function testInvalidGrantExtension()
445445
{
446-
$client = $this->getMock('OAuth2\Model\IOAuth2Client');
446+
$client = $this->createMock('OAuth2\Model\IOAuth2Client');
447447
$this->storage->checkGrantExtension($client, 'https://friendsofsymfony.com/grants/bar', array(), array());
448448
}
449449

450450
public function testDoubleSetGrantExtension()
451451
{
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');
454454
$this->storage->setGrantExtension($uri = 'https://friendsofsymfony.com/grants/foo', $grantExtension);
455455
$this->storage->setGrantExtension($uri, $grantExtension2);
456456

@@ -464,7 +464,7 @@ public function testDoubleSetGrantExtension()
464464

465465
public function testMarkAuthCodeAsUsedIfAuthCodeFound()
466466
{
467-
$authCode = $this->getMock('FOS\OAuthServerBundle\Model\AuthCodeInterface');
467+
$authCode = $this->createMock('FOS\OAuthServerBundle\Model\AuthCodeInterface');
468468

469469
$this->authCodeManager->expects($this->atLeastOnce())
470470
->method('findAuthCodeByToken')

0 commit comments

Comments
 (0)