8000 fixed obsolete getMock() usage · symfony/security-core@ca19911 · GitHub
[go: up one dir, main page]

Skip to content

Commit ca19911

Browse files
committed
fixed obsolete getMock() usage
1 parent 23794b5 commit ca19911

23 files changed

+137
-137
lines changed

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
F438 ->method('authenticate')
142-
->will($this->throwException($this->getMock($exception, null, array(), '')))
142+
->will($this->throwException($this->getMockBuilder($exception)->setMethods(null)->getMock()))
143143
;
144144
}
145145

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()

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)
0