Skip to content

Commit a7d05cd

Browse files
committed
fixed obsolete getMock() usage
1 parent 1a88fc7 commit a7d05cd

31 files changed

+316
-316
lines changed

Tests/AccessMapTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AccessMapTest extends \PHPUnit_Framework_TestCase
1717
{
1818
public function testReturnsFirstMatchedPattern()
1919
{
20-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
20+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
2121
$requestMatcher1 = $this->getRequestMatcher($request, false);
2222
$requestMatcher2 = $this->getRequestMatcher($request, true);
2323

@@ -30,7 +30,7 @@ public function testReturnsFirstMatchedPattern()
3030

3131
public function testReturnsEmptyPatternIfNoneMatched()
3232
{
33-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
33+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
3434
$requestMatcher = $this->getRequestMatcher($request, false);
3535

3636
$map = new AccessMap();
@@ -41,7 +41,7 @@ public function testReturnsEmptyPatternIfNoneMatched()
4141

4242
private function getRequestMatcher($request, $matches)
4343
{
44-
$requestMatcher = $this->getMock('Symfony\Component\HttpFoundation\RequestMatcherInterface');
44+
$requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock();
4545
$requestMatcher->expects($this->once())
4646
->method('matches')->with($request)
4747
->will($this->returnValue($matches));

Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ class DefaultAuthenticationFailureHandlerTest extends \PHPUnit_Framework_TestCas
3232

3333
protected function setUp()
3434
{
35-
$this->httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
36-
$this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
37-
$this->logger = $this->getMock('Psr\Log\LoggerInterface');
35+
$this->httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
36+
$this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
37+
$this->logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
3838

39-
$this->session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
40-
$this->request = $this->getMock('Symfony\Component\HttpFoundation\Request');
39+
$this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
40+
$this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
4141
$this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session));
42-
$this->exception = $this->getMock('Symfony\Component\Security\Core\Exception\AuthenticationException', array('getMessage'));
42+
$this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(array('getMessage'))->getMock();
4343
}
4444

4545
public function testForward()
@@ -173,8 +173,8 @@ public function testFailurePathParameterCanBeOverwritten()
173173

174174
private function getRequest()
175175
{
176-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
177-
$request->attributes = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag');
176+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
177+
$request->attributes = $this->getMockBuilder('Symfony\Component\HttpFoundation\ParameterBag')->getMock();
178178

179179
return $request;
180180
}

Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class DefaultAuthenticationSuccessHandlerTest extends \PHPUnit_Framework_TestCas
2424

2525
protected function setUp()
2626
{
27-
$this->httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
28-
$this->request = $this->getMock('Symfony\Component\HttpFoundation\Request');
29-
$this->request->headers = $this->getMock('Symfony\Component\HttpFoundation\HeaderBag');
30-
$this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
27+
$this->httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
28+
$this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
29+
$this->request->headers = $this->getMockBuilder('Symfony\Component\HttpFoundation\HeaderBag')->getMock();
30+
$this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
3131
}
3232

3333
public function testRequestIsRedirected()
@@ -87,7 +87,7 @@ public function testTargetPathParameterIsCustomised()
8787

8888
public function testTargetPathIsTakenFromTheSession()
8989
{
90-
$session = $this->getMock('Symfony\Component\HttpFoundation\Session\SessionInterface');
90+
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
9191
$session->expects($this->once())
9292
->method('get')->with('_security.admin.target_path')
9393
->will($this->returnValue('/admin/dashboard'));

Tests/Authentication/SimpleAuthenticationHandlerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class SimpleAuthenticationHandlerTest extends \PHPUnit_Framework_TestCase
3434

3535
protected function setUp()
3636
{
37-
$this->successHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface');
38-
$this->failureHandler = $this->getMock('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface');
37+
$this->successHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface')->getMock();
38+
$this->failureHandler = $this->getMockBuilder('Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface')->getMock();
3939

40-
$this->request = $this->getMock('Symfony\Component\HttpFoundation\Request');
41-
$this->token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
40+
$this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
41+
$this->token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
4242
// No methods are invoked on the exception; we just assert on its class
4343
$this->authenticationException = new AuthenticationException();
4444

@@ -47,7 +47,7 @@ protected function setUp()
4747

4848
public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNotASuccessHandler()
4949
{
50-
$authenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface');
50+
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
5151

5252
$this->successHandler->expects($this->once())
5353
->method('onAuthenticationSuccess')
@@ -117,7 +117,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu
117117

118118
public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNotAFailureHandler()
119119
{
120-
$authenticator = $this->getMock('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface');
120+
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
121121

122122
$this->failureHandler->expects($this->once())
123123
->method('onAuthenticationFailure')

Tests/EntryPoint/BasicAuthenticationEntryPointTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class BasicAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
1818
{
1919
public function testStart()
2020
{
21-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
21+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
2222

2323
$authException = new AuthenticationException('The exception message');
2424

@@ -31,7 +31,7 @@ public function testStart()
3131

3232
public function testStartWithoutAuthException()
3333
{
34-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
34+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
3535

3636
$entryPoint = new BasicAuthenticationEntryPoint('TheRealmName');
3737

Tests/EntryPoint/DigestAuthenticationEntryPointTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class DigestAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
1919
{
2020
public function testStart()
2121
{
22-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
22+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
2323

2424
$authenticationException = new AuthenticationException('TheAuthenticationExceptionMessage');
2525

@@ -32,7 +32,7 @@ public function testStart()
3232

3333
public function testStartWithNoException()
3434
{
35-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
35+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
3636

3737
$entryPoint = new DigestAuthenticationEntryPoint('TheRealmName', 'TheKey');
3838
$response = $entryPoint->start($request);
@@ -43,7 +43,7 @@ public function testStartWithNoException()
4343

4444
public function testStartWithNonceExpiredException()
4545
{
46-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request');
46+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
4747

4848
$nonceExpiredException = new NonceExpiredException('TheNonceExpiredExceptionMessage');
4949

Tests/EntryPoint/FormAuthenticationEntryPointTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class FormAuthenticationEntryPointTest extends \PHPUnit_Framework_TestCase
1919
{
2020
public function testStart()
2121
{
22-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
22+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
2323
$response = new Response();
2424

25-
$httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
26-
$httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
25+
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
26+
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
2727
$httpUtils
2828
->expects($this->once())
2929
->method('createRedirectResponse')
@@ -38,19 +38,19 @@ public function testStart()
3838

3939
public function testStartWithUseForward()
4040
{
41-
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
42-
$subRequest = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);
41+
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
42+
$subRequest = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->disableOriginalConstructor()->disableOriginalClone()->getMock();
4343
$response = new Response('', 200);
4444

45-
$httpUtils = $this->getMock('Symfony\Component\Security\Http\HttpUtils');
45+
$httpUtils = $this->getMockBuilder('Symfony\Component\Security\Http\HttpUtils')->getMock();
4646
$httpUtils
4747
->expects($this->once())
4848
->method('createRequest')
4949
->with($this->equalTo($request), $this->equalTo('/the/login/path'))
5050
->will($this->returnValue($subRequest))
5151
;
5252

53-
$httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
53+
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
5454
$httpKernel
5555
->expects($this->once())
5656
->method('handle')

Tests/Firewall/AbstractPreAuthenticatedListenerTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public function testHandleWithValidValues()
2424

2525
$request = new Request(array(), array(), array(), array(), array(), array());
2626

27-
$token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
27+
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
2828

29-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
29+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
3030
$tokenStorage
3131
->expects($this->any())
3232
->method('getToken')
@@ -38,7 +38,7 @@ public function testHandleWithValidValues()
3838
->with($this->equalTo($token))
3939
;
4040

41-
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
41+
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
4242
$authenticationManager
4343
->expects($this->once())
4444
->method('authenticate')
@@ -56,7 +56,7 @@ public function testHandleWithValidValues()
5656
->method('getPreAuthenticatedData')
5757
->will($this->returnValue($userCredentials));
5858

59-
$event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
59+
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
6060
$event
6161
->expects($this->any())
6262
->method('getRequest')
@@ -72,7 +72,7 @@ public function testHandleWhenAuthenticationFails()
7272

7373
$request = new Request(array(), array(), array(), array(), array(), array());
7474

75-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
75+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
7676
$tokenStorage
7777
->expects($this->any())
7878
->method('getToken')
@@ -84,7 +84,7 @@ public function testHandleWhenAuthenticationFails()
8484
;
8585

8686
$exception = new AuthenticationException('Authentication failed.');
87-
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
87+
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
8888
$authenticationManager
8989
->expects($this->once())
9090
->method('authenticate')
@@ -102,7 +102,7 @@ public function testHandleWhenAuthenticationFails()
102102
->method('getPreAuthenticatedData')
103103
->will($this->returnValue($userCredentials));
104104

105-
$event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
105+
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
106106
$event
107107
->expects($this->any())
108108
->method('getRequest')
@@ -120,7 +120,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken()
120120

121121
$request = new Request(array(), array(), array(), array(), array(), array());
122122

123-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
123+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
124124
$tokenStorage
125125
->expects($this->any())
126126
->method('getToken')
@@ -132,7 +132,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken()
132132
;
133133

134134
$exception = new AuthenticationException('Authentication failed.');
135-
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
135+
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
136136
$authenticationManager
137137
->expects($this->once())
138138
->method('authenticate')
@@ -150,7 +150,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken()
150150
->method('getPreAuthenticatedData')
151151
->will($this->returnValue($userCredentials));
152152

153-
$event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
153+
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
154154
$event
155155
->expects($this->any())
156156
->method('getRequest')
@@ -168,14 +168,14 @@ public function testHandleWithASimilarAuthenticatedToken()
168168

169169
$token = new PreAuthenticatedToken('TheUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO'));
170170

171-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
171+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
172172
$tokenStorage
173173
->expects($this->any())
174174
->method('getToken')
175175
->will($this->returnValue($token))
176176
;
177177

178-
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
178+
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
179179
$authenticationManager
180180
->expects($this->never())
181181
->method('authenticate')
@@ -191,7 +191,7 @@ public function testHandleWithASimilarAuthenticatedToken()
191191
->method('getPreAuthenticatedData')
192192
->will($this->returnValue($userCredentials));
193193

194-
$event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
194+
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
195195
$event
196196
->expects($this->any())
197197
->method('getRequest')
@@ -209,7 +209,7 @@ public function testHandleWithAnInvalidSimilarToken()
209209

210210
$token = new PreAuthenticatedToken('AnotherUser', 'TheCredentials', 'TheProviderKey', array('ROLE_FOO'));
211211

212-
$tokenStorage = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
212+
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
213213
$tokenStorage
214214
->expects($this->any())
215215
->method('getToken')
@@ -222,7 +222,7 @@ public function testHandleWithAnInvalidSimilarToken()
222222
;
223223

224224
$exception = new AuthenticationException('Authentication failed.');
225-
$authenticationManager = $this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface');
225+
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
226226
$authenticationManager
227227
->expects($this->once())
228228
->method('authenticate')
@@ -240,7 +240,7 @@ public function testHandleWithAnInvalidSimilarToken()
240240
->method('getPreAuthenticatedData')
241241
->will($this->returnValue($userCredentials));
242242

243-
$event = $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
243+
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
244244
$event
245245
->expects($this->any())
246246
->method('getRequest')

0 commit comments

Comments
 (0)