Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 0582ad2

Browse files
committed
fixed obsolete getMock() usage
1 parent e396644 commit 0582ad2

File tree

66 files changed

+488
-488
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+488
-488
lines changed

Acl/Tests/Dbal/MutableAclProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public function testUpdateAclDoesNotAcceptUntrackedAcls()
255255

256256
public function testUpdateDoesNothingWhenThereAreNoChanges()
257257
{
258-
$con = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
258+
$con = $this->getMockBuilder('Doctrine\DBAL\Connection')->disableOriginalConstructor()->getMock();
259259
$con
260260
->expects($this->never())
261261
->method('beginTransaction')

Acl/Tests/Domain/AclTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function testIsFieldGranted()
208208
{
209209
$sids = array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity('ROLE_IDDQD'));
210210
$masks = array(1, 2, 4);
211-
$strategy = $this->getMock('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface');
211+
$strategy = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface')->getMock();
212212
$acl = new Acl(1, new ObjectIdentity(1, 'foo'), $strategy, array(), true);
213213

214214
$strategy
@@ -225,7 +225,7 @@ public function testIsGranted()
225225
{
226226
$sids = array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity('ROLE_IDDQD'));
227227
$masks = array(1, 2, 4);
228-
$strategy = $this->getMock('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface');
228+
$strategy = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface')->getMock();
229229
$acl = new Acl(1, new ObjectIdentity(1, 'foo'), $strategy, array(), true);
230230

231231
$strategy
@@ -488,7 +488,7 @@ protected function getListener($expectedChanges)
488488
{
489489
$aceProperties = array('aceOrder', 'mask', 'strategy', 'auditSuccess', 'auditFailure');
490490

491-
$listener = $this->getMock('Doctrine\Common\PropertyChangedListener');
491+
$listener = $this->getMockBuilder('Doctrine\Common\PropertyChangedListener')->getMock();
492492
foreach ($expectedChanges as $index => $property) {
493493
if (in_array($property, $aceProperties)) {
494494
$class = 'Symfony\Component\Security\Acl\Domain\Entry';

Acl/Tests/Domain/AuditLoggerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getTestLogData()
7373

7474
protected function getEntry()
7575
{
76-
return $this->getMock('Symfony\Component\Security\Acl\Model\AuditableEntryInterface');
76+
return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AuditableEntryInterface')->getMock();
7777
}
7878

7979
protected function getLogger()

Acl/Tests/Domain/EntryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ protected function getAce($acl = null, $sid = null)
109109

110110
protected function getAcl()
111111
{
112-
return $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface');
112+
return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock();
113113
}
114114

115115
protected function getSid()
116116
{
117-
return $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface');
117+
return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface')->getMock();
118118
}
119119
}

Acl/Tests/Domain/FieldEntryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ protected function getAce($acl = null, $sid = null)
6464

6565
protected function getAcl()
6666
{
67-
return $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface');
67+
return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock();
6868
}
6969

7070
protected function getSid()
7171
{
72-
return $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface');
72+
return $this->getMockBuilder('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface')->getMock();
7373
}
7474
}

Acl/Tests/Domain/PermissionGrantingStrategyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testIsGrantedCallsAuditLoggerOnGrant()
107107
$acl = $this->getAcl($strategy);
108108
$sid = new UserSecurityIdentity('johannes', 'Foo');
109109

110-
$logger = $this->getMock('Symfony\Component\Security\Acl\Model\AuditLoggerInterface');
110+
$logger = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AuditLoggerInterface')->getMock();
111111
$logger
112112
->expects($this->once())
113113
->method('logIfNeeded')
@@ -126,7 +126,7 @@ public function testIsGrantedCallsAuditLoggerOnDeny()
126126
$acl = $this->getAcl($strategy);
127127
$sid = new UserSecurityIdentity('johannes', 'Foo');
128128

129-
$logger = $this->getMock('Symfony\Component\Security\Acl\Model\AuditLoggerInterface');
129+
$logger = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AuditLoggerInterface')->getMock();
130130
$logger
131131
->expects($this->once())
132132
->method('logIfNeeded')

Acl/Tests/Domain/SecurityIdentityRetrievalStrategyTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function getSecurityIdentityRetrievalTests()
109109

110110
protected function getAccount($username, $class)
111111
{
112-
$account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface', array(), array(), $class);
112+
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->setMockClassName($class)->getMock();
113113
$account
114114
->expects($this->any())
115115
->method('getUsername')
@@ -121,15 +121,15 @@ protected function getAccount($username, $class)
121121

122122
protected function getStrategy(array $roles = array(), $authenticationStatus = 'fullFledged')
123123
{
124-
$roleHierarchy = $this->getMock('Symfony\Component\Security\Core\Role\RoleHierarchyInterface');
124+
$roleHierarchy = $this->getMockBuilder('Symfony\Component\Security\Core\Role\RoleHierarchyInterface')->getMock();
125125
$roleHierarchy
126126
->expects($this->once())
127127
->method('getReachableRoles')
128128
->with($this->equalTo(array('foo')))
129129
->will($this->returnValue($roles))
130130
;
131131

132-
$trustResolver = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver', array(), array('', ''));
132+
$trustResolver = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver')->setConstructorArgs(array('', ''))->getMock();
133133

134134
$trustResolver
135135
->expects($this->at(0))

Acl/Tests/Domain/UserSecurityIdentityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getCompareData()
5252
->will($this->returnValue('foo'))
5353
;
5454

55-
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
55+
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
5656
$token
5757
->expects($this->any())
5858
->method('getUser')

Acl/Tests/Voter/AclVoterTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function testVoteGrantsAccess($grant)
213213
->expects($this->once())
214214
->method('findAcl')
215215
->with($this->equalTo($oid), $this->equalTo($sids))
216-
->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface')))
216+
->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock()))
217217
;
218218

219219
$acl
@@ -259,7 +259,7 @@ public function testVoteNoAceFound()
259259
->expects($this->once())
260260
->method('findAcl')
261261
->with($this->equalTo($oid), $this->equalTo($sids))
262-
->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface')))
262+
->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock()))
263263
;
264264

265265
$acl
@@ -302,7 +302,7 @@ public function testVoteGrantsFieldAccess($grant)
302302
->expects($this->once())
303303
->method('findAcl')
304304
->with($this->equalTo($oid), $this->equalTo($sids))
305-
->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface')))
305+
->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock()))
306306
;
307307

308308
$acl
@@ -348,7 +348,7 @@ public function testVoteNoFieldAceFound()
348348
->expects($this->once())
349349
->method('findAcl')
350350
->with($this->equalTo($oid), $this->equalTo($sids))
351-
->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface')))
351+
->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock()))
352352
;
353353

354354
$acl
@@ -389,7 +389,7 @@ public function testWhenReceivingAnObjectIdentityInterfaceWeDontRetrieveANewObje
389389
->expects($this->once())
390390
->method('findAcl')
391391
->with($this->equalTo($oid), $this->equalTo($sids))
392-
->will($this->returnValue($acl = $this->getMock('Symfony\Component\Security\Acl\Model\AclInterface')))
392+
->will($this->returnValue($acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclInterface')->getMock()))
393393
;
394394

395395
$acl
@@ -404,15 +404,15 @@ public function testWhenReceivingAnObjectIdentityInterfaceWeDontRetrieveANewObje
404404

405405
protected function getToken()
406406
{
407-
return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
407+
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
408408
}
409409

410410
protected function getVoter($allowIfObjectIdentityUnavailable = true, $alwaysContains = true)
411411
{
412-
$provider = $this->getMock('Symfony\Component\Security\Acl\Model\AclProviderInterface');
413-
$permissionMap = $this->getMock('Symfony\Component\Security\Acl\Permission\PermissionMapInterface');
414-
$oidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface');
415-
$sidStrategy = $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface');
412+
$provider = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\AclProviderInterface')->getMock();
413+
$permissionMap = $this->getMockBuilder('Symfony\Component\Security\Acl\Permission\PermissionMapInterface')->getMock();
414+
$oidStrategy = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface')->getMock();
415+
$sidStrategy = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface')->getMock();
416416

417417
if ($alwaysContains) {
418418
$permissionMap

Core/Tests/Authentication/AuthenticationProviderManagerTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testAuthenticateWhenNoProviderSupportsToken()
4444
));
4545

4646
try {
47-
$manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
47+
$manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
4848
$this->fail();
4949
} catch (ProviderNotFoundException $e) {
5050
$this->assertSame($token, $e->getToken());
@@ -58,7 +58,7 @@ public function testAuthenticateWhenProviderReturnsAccountStatusException()
5858
));
5959

6060
try {
61-
$manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
61+
$manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
6262
$this->fail();
6363
} catch (AccountStatusException $e) {
6464
$this->assertSame($token, $e->getToken());
@@ -72,7 +72,7 @@ public function testAuthenticateWhenProviderReturnsAuthenticationException()
7272
));
7373

7474
try {
75-
$manager->authenticate($token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
75+
$manager->authenticate($token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
7676
$this->fail();
7777
} catch (AuthenticationException $e) {
7878
$this->assertSame($token, $e->getToken());
@@ -83,26 +83,26 @@ public function testAuthenticateWhenOneReturnsAuthenticationExceptionButNotAll()
8383
{
8484
$manager = new AuthenticationProviderManager(array(
8585
$this->getAuthenticationProvider(true, null, 'Symfony\Component\Security\Core\Exception\AuthenticationException'),
86-
$this->getAuthenticationProvider(true, $expected = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')),
86+
$this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()),
8787
));
8888

89-
$token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
89+
$token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
9090
$this->assertSame($expected, $token);
9191
}
9292

9393
public function testAuthenticateReturnsTokenOfTheFirstMatchingProvider()
9494
{
95-
$second = $this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface');
95+
$second = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
9696
$second
9797
->expects($this->never())
9898
->method('supports')
9999
;
100100
$manager = new AuthenticationProviderManager(array(
101-
$this->getAuthenticationProvider(true, $expected = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')),
101+
$this->getAuthenticationProvider(true, $expected = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()),
102102
$second,
103103
));
104104

105-
$token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
105+
$token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
106106
$this->assertSame($expected, $token);
107107
}
108108

@@ -112,20 +112,20 @@ public function testEraseCredentialFlag()
112112
$this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')),
113113
));
114114

115-
$token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
115+
$token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
116116
$this->assertEquals('', $token->getCredentials());
117117

118118
$manager = new AuthenticationProviderManager(array(
119119
$this->getAuthenticationProvider(true, $token = new UsernamePasswordToken('foo', 'bar', 'key')),
120120
), false);
121121

122-
$token = $manager->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'));
122+
$token = $manager->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
123123
$this->assertEquals('bar', $token->getCredentials());
124124
}
125125

126126
protected function getAuthenticationProvider($supports, $token = null, $exception = null)
127127
{
128-
$provider = $this->getMock('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface');
128+
$provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
129129
$provider->expects($this->once())
130130
->method('supports')
131131
->will($this->returnValue($supports))
@@ -139,7 +139,7 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio
139139
} elseif (null !== $exception) {
140140
$provider->expects($this->once())
141141
->method('authenticate')
142-
->will($this->throwException($this->getMock($exception, null, array(), '')))
142+
->will($this->throwException($this->getMockBuilder($exception)->setMethods(null)->getMock()))
143143
;
144144
}
145145

Core/Tests/Authentication/AuthenticationTrustResolverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ public function testisFullFledged()
4747

4848
protected function getToken()
4949
{
50-
return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
50+
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
5151
}
5252

5353
protected function getAnonymousToken()
5454
{
55-
return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', null, array('', ''));
55+
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setConstructorArgs(array('', ''))->getMock();
5656
}
5757

5858
protected function getRememberMeToken()
5959
{
60-
return $this->getMock('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken', array('setPersistent'), array(), '', false);
60+
return $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(array('setPersistent'))->disableOriginalConstructor()->getMock();
6161
}
6262

6363
protected function getResolver()

Core/Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public function testSupports()
2020
$provider = $this->getProvider('foo');
2121

2222
$this->assertTrue($provider->supports($this->getSupportedToken('foo')));
23-
$this->assertFalse($provider->supports($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
23+
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
2424
}
2525

2626
public function testAuthenticateWhenTokenIsNotSupported()
2727
{
2828
$provider = $this->getProvider('foo');
2929

30-
$this->assertNull($provider->authenticate($this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')));
30+
$this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
3131
}
3232

3333
/**
@@ -50,7 +50,7 @@ public function testAuthenticate()
5050

5151
protected function getSupportedToken($key)
5252
{
53-
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken', array('getKey'), array(), '', false);
53+
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(array('getKey'))->disableOriginalConstructor()->getMock();
5454
$token->expects($this->any())
5555
->method('getKey')
5656
->will($this->returnValue($key))

0 commit comments

Comments
 (0)