Skip to content

Commit 3e37499

Browse files
Merge branch '3.4' into 4.2
* 3.4: Use willReturn() instead of will(returnValue()).
2 parents 9d63e1b + 8e80d4e commit 3e37499

28 files changed

+227
-227
lines changed

Tests/AccessMapTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private function getRequestMatcher($request, $matches)
4545
$requestMatcher = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestMatcherInterface')->getMock();
4646
$requestMatcher->expects($this->once())
4747
->method('matches')->with($request)
48-
->will($this->returnValue($matches));
48+
->willReturn($matches);
4949

5050
return $requestMatcher;
5151
}

Tests/Authentication/DefaultAuthenticationFailureHandlerTest.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function setUp()
3434

3535
$this->session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
3636
$this->request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
37-
$this->request->expects($this->any())->method('getSession')->will($this->returnValue($this->session));
37+
$this->request->expects($this->any())->method('getSession')->willReturn($this->session);
3838
$this->exception = $this->getMockBuilder('Symfony\Component\Security\Core\Exception\AuthenticationException')->setMethods(['getMessage'])->getMock();
3939
}
4040

@@ -47,12 +47,12 @@ public function testForward()
4747
->method('set')->with(Security::AUTHENTICATION_ERROR, $this->exception);
4848
$this->httpUtils->expects($this->once())
4949
->method('createRequest')->with($this->request, '/login')
50-
->will($this->returnValue($subRequest));
50+
->willReturn($subRequest);
5151

5252
$response = new Response();
5353
$this->httpKernel->expects($this->once())
5454
->method('handle')->with($subRequest, HttpKernelInterface::SUB_REQUEST)
55-
->will($this->returnValue($response));
55+
->willReturn($response);
5656

5757
$handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, $options, $this->logger);
5858
$result = $handler->onAuthenticationFailure($this->request, $this->exception);
@@ -65,7 +65,7 @@ public function testRedirect()
6565
$response = new Response();
6666
$this->httpUtils->expects($this->once())
6767
->method('createRedirectResponse')->with($this->request, '/login')
68-
->will($this->returnValue($response));
68+
->willReturn($response);
6969

7070
$handler = new DefaultAuthenticationFailureHandler($this->httpKernel, $this->httpUtils, [], $this->logger);
7171
$result = $handler->onAuthenticationFailure($this->request, $this->exception);
@@ -92,7 +92,7 @@ public function testExceptionIsPassedInRequestOnForward()
9292

9393
$this->httpUtils->expects($this->once())
9494
->method('createRequest')->with($this->request, '/login')
95-
->will($this->returnValue($subRequest));
95+
->willReturn($subRequest);
9696

9797
$this->session->expects($this->never())->method('set');
9898

@@ -117,7 +117,7 @@ public function testForwardIsLogged()
117117

118118
$this->httpUtils->expects($this->once())
119119
->method('createRequest')->with($this->request, '/login')
120-
->will($this->returnValue($this->getRequest()));
120+
->willReturn($this->getRequest());
121121

122122
$this->logger
123123
->expects($this->once())
@@ -143,7 +143,7 @@ public function testFailurePathCanBeOverwrittenWithRequest()
143143
{
144144
$this->request->expects($this->once())
145145
->method('get')->with('_failure_path')
146-
->will($this->returnValue('/auth/login'));
146+
->willReturn('/auth/login');
147147

148148
$this->httpUtils->expects($this->once())
149149
->method('createRedirectResponse')->with($this->request, '/auth/login');
@@ -156,7 +156,7 @@ public function testFailurePathCanBeOverwrittenWithNestedAttributeInRequest()
156156
{
157157
$this->request->expects($this->once())
158158
->method('get')->with('_failure_path')
159-
->will($this->returnValue(['value' => '/auth/login']));
159+
->willReturn(['value' => '/auth/login']);
160160

161161
$this->httpUtils->expects($this->once())
162162
->method('createRedirectResponse')->with($this->request, '/auth/login');
@@ -171,7 +171,7 @@ public function testFailurePathParameterCanBeOverwritten()
171171

172172
$this->request->expects($this->once())
173173
->method('get')->with('_my_failure_path')
174-
->will($this->returnValue('/auth/login'));
174+
->willReturn('/auth/login');
175175

176176
$this->httpUtils->expects($this->once())
177177
->method('createRedirectResponse')->with($this->request, '/auth/login');

Tests/Authentication/DefaultAuthenticationSuccessHandlerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DefaultAuthenticationSuccessHandlerTest extends TestCase
2424
public function testRequestRedirections(Request $request, $options, $redirectedUrl)
2525
{
2626
$urlGenerator = $this->getMockBuilder('Symfony\Component\Routing\Generator\UrlGeneratorInterface')->getMock();
27-
$urlGenerator->expects($this->any())->method('generate')->will($this->returnValue('http://localhost/login'));
27+
$urlGenerator->expects($this->any())->method('generate')->willReturn('http://localhost/login');
2828
$httpUtils = new HttpUtils($urlGenerator);
2929
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
3030
$handler = new DefaultAuthenticationSuccessHandler($httpUtils, $options);
@@ -37,7 +37,7 @@ public function testRequestRedirections(Request $request, $options, $redirectedU
3737
public function getRequestRedirections()
3838
{
3939
$session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
40-
$session->expects($this->once())->method('get')->with('_security.admin.target_path')->will($this->returnValue('/admin/dashboard'));
40+
$session->expects($this->once())->method('get')->with('_security.admin.target_path')->willReturn('/admin/dashboard');
4141
$session->expects($this->once())->method('remove')->with('_security.admin.target_path');
4242
$requestWithSession = Request::create('/');
4343
$requestWithSession->setSession($session);

Tests/Authentication/SimpleAuthenticationHandlerTest.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfSimpleIsNo
5656
$this->successHandler->expects($this->once())
5757
->method('onAuthenticationSuccess')
5858
->with($this->request, $this->token)
59-
->will($this->returnValue($this->response));
59+
->willReturn($this->response);
6060

6161
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
6262
$result = $handler->onAuthenticationSuccess($this->request, $this->token);
@@ -73,7 +73,7 @@ public function testOnAuthenticationSuccessCallsSimpleAuthenticator()
7373
$authenticator->expects($this->once())
7474
->method('onAuthenticationSuccess')
7575
->with($this->request, $this->token)
76-
->will($this->returnValue($this->response));
76+
->willReturn($this->response);
7777

7878
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
7979
$result = $handler->onAuthenticationSuccess($this->request, $this->token);
@@ -94,7 +94,7 @@ public function testOnAuthenticationSuccessThrowsAnExceptionIfNonResponseIsRetur
9494
$authenticator->expects($this->once())
9595
->method('onAuthenticationSuccess')
9696
->with($this->request, $this->token)
97-
->will($this->returnValue(new \stdClass()));
97+
->willReturn(new \stdClass());
9898

9999
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
100100
$handler->onAuthenticationSuccess($this->request, $this->token);
@@ -105,13 +105,13 @@ public function testOnAuthenticationSuccessFallsBackToDefaultHandlerIfNullIsRetu
105105
$this->successHandler->expects($this->once())
106106
->method('onAuthenticationSuccess')
107107
->with($this->request, $this->token)
108-
->will($this->returnValue($this->response));
108+
->willReturn($this->response);
109109

110110
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestSuccessHandlerInterface');
111111
$authenticator->expects($this->once())
112112
->method('onAuthenticationSuccess')
113113
->with($this->request, $this->token)
114-
->will($this->returnValue(null));
114+
->willReturn(null);
115115

116116
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
117117
$result = $handler->onAuthenticationSuccess($this->request, $this->token);
@@ -126,7 +126,7 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfSimpleIsNo
126126
$this->failureHandler->expects($this->once())
127127
->method('onAuthenticationFailure')
128128
->with($this->request, $this->authenticationException)
129-
->will($this->returnValue($this->response));
129+
->willReturn($this->response);
130130

131131
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
132132
$result = $handler->onAuthenticationFailure($this->request, $this->authenticationException);
@@ -143,7 +143,7 @@ public function testOnAuthenticationFailureCallsSimpleAuthenticator()
143143
$authenticator->expects($this->once())
144144
->method('onAuthenticationFailure')
145145
->with($this->request, $this->authenticationException)
146-
->will($this->returnValue($this->response));
146+
->willReturn($this->response);
147147

148148
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
149149
$result = $handler->onAuthenticationFailure($this->request, $this->authenticationException);
@@ -164,7 +164,7 @@ public function testOnAuthenticationFailureThrowsAnExceptionIfNonResponseIsRetur
164164
$authenticator->expects($this->once())
165165
->method('onAuthenticationFailure')
166166
->with($this->request, $this->authenticationException)
167-
->will($this->returnValue(new \stdClass()));
167+
->willReturn(new \stdClass());
168168

169169
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
170170
$handler->onAuthenticationFailure($this->request, $this->authenticationException);
@@ -175,13 +175,13 @@ public function testOnAuthenticationFailureFallsBackToDefaultHandlerIfNullIsRetu
175175
$this->failureHandler->expects($this->once())
176176
->method('onAuthenticationFailure')
177177
->with($this->request, $this->authenticationException)
178-
->will($this->returnValue($this->response));
178+
->willReturn($this->response);
179179

180180
$authenticator = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Tests\TestFailureHandlerInterface');
181181
$authenticator->expects($this->once())
182182
->method('onAuthenticationFailure')
183183
->with($this->request, $this->authenticationException)
184-
->will($this->returnValue(null));
184+
->willReturn(null);
185185

186186
$handler = new SimpleAuthenticationHandler($authenticator, $this->successHandler, $this->failureHandler);
187187
$result = $handler->onAuthenticationFailure($this->request, $this->authenticationException);

Tests/EntryPoint/FormAuthenticationEntryPointTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testStart()
2929
->expects($this->once())
3030
->method('createRedirectResponse')
3131
->with($this->equalTo($request), $this->equalTo('/the/login/path'))
32-
->will($this->returnValue($response))
32+
->willReturn($response)
3333
;
3434

3535
$entryPoint = new FormAuthenticationEntryPoint($httpKernel, $httpUtils, '/the/login/path', false);
@@ -48,15 +48,15 @@ public function testStartWithUseForward()
4848
->expects($this->once())
4949
->method('createRequest')
5050
->with($this->equalTo($request), $this->equalTo('/the/login/path'))
51-
->will($this->returnValue($subRequest))
51+
->willReturn($subRequest)
5252
;
5353

5454
$httpKernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
5555
$httpKernel
5656
->expects($this->once())
5757
->method('handle')
5858
->with($this->equalTo($subRequest), $this->equalTo(HttpKernelInterface::SUB_REQUEST))
59-
->will($this->returnValue($response))
59+
->willReturn($response)
6060
;
6161

6262
$entryPoint = new FormAuthenticationEntryPoint($httpKernel, $httpUtils, '/the/login/path', true);

Tests/Firewall/AbstractPreAuthenticatedListenerTest.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testHandleWithValidValues()
3131
$tokenStorage
3232
->expects($this->any())
3333
->method('getToken')
34-
->will($this->returnValue(null))
34+
->willReturn(null)
3535
;
3636
$tokenStorage
3737
->expects($this->once())
@@ -44,7 +44,7 @@ public function testHandleWithValidValues()
4444
->expects($this->once())
4545
->method('authenticate')
4646
->with($this->isInstanceOf('Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken'))
47-
->will($this->returnValue($token))
47+
->willReturn($token)
4848
;
4949

5050
$listener = $this->getMockForAbstractClass('Symfony\Component\Security\Http\Firewall\AbstractPreAuthenticatedListener', [
@@ -55,13 +55,13 @@ public function testHandleWithValidValues()
5555
$listener
5656
->expects($this->once())
5757
->method('getPreAuthenticatedData')
58-
->will($this->returnValue($userCredentials));
58+
->willReturn($userCredentials);
5959

6060
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
6161
$event
6262
->expects($this->any())
6363
->method('getRequest')
64-
->will($this->returnValue($request))
64+
->willReturn($request)
6565
;
6666

6767
$listener->handle($event);
@@ -77,7 +77,7 @@ public function testHandleWhenAuthenticationFails()
7777
$tokenStorage
7878
->expects($this->any())
7979
->method('getToken')
80-
->will($this->returnValue(null))
80+
->willReturn(null)
8181
;
8282
$tokenStorage
8383
->expects($this->never())
@@ -101,13 +101,13 @@ public function testHandleWhenAuthenticationFails()
101101
$listener
102102
->expects($this->once())
103103
->method('getPreAuthenticatedData')
104-
->will($this->returnValue($userCredentials));
104+
->willReturn($userCredentials);
105105

106106
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
107107
$event
108108
->expects($this->any())
109109
->method('getRequest')
110-
->will($this->returnValue($request))
110+
->willReturn($request)
111111
;
112112

113113
$listener->handle($event);
@@ -125,7 +125,7 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken()
125125
$tokenStorage
126126
->expects($this->any())
127127
->method('getToken')
128-
->will($this->returnValue($token))
128+
->willReturn($token)
129129
;
130130
$tokenStorage
131131
->expects($this->never())
@@ -149,13 +149,13 @@ public function testHandleWhenAuthenticationFailsWithDifferentToken()
149149
$listener
150150
->expects($this->once())
151151
->method('getPreAuthenticatedData')
152-
->will($this->returnValue($userCredentials));
152+
->willReturn($userCredentials);
153153

154154
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
155155
$event
156156
->expects($this->any())
157157
->method('getRequest')
158-
->will($this->returnValue($request))
158+
->willReturn($request)
159159
;
160160

161161
$listener->handle($event);
@@ -173,7 +173,7 @@ public function testHandleWithASimilarAuthenticatedToken()
173173
$tokenStorage
174174
->expects($this->any())
175175
->method('getToken')
176-
->will($this->returnValue($token))
176+
->willReturn($token)
177177
;
178178

179179
$authenticationManager = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')->getMock();
@@ -190,13 +190,13 @@ public function testHandleWithASimilarAuthenticatedToken()
190190
$listener
191191
->expects($this->once())
192192
->method('getPreAuthenticatedData')
193-
->will($this->returnValue($userCredentials));
193+
->willReturn($userCredentials);
194194

195195
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
196196
$event
197197
->expects($this->any())
198198
->method('getRequest')
199-
->will($this->returnValue($request))
199+
->willReturn($request)
200200
;
201201

202202
$listener->handle($event);
@@ -214,7 +214,7 @@ public function testHandleWithAnInvalidSimilarToken()
214214
$tokenStorage
215215
->expects($this->any())
216216
->method('getToken')
217-
->will($this->returnValue($token))
217+
->willReturn($token)
218218
;
219219
$tokenStorage
220220
->expects($this->once())
@@ -239,13 +239,13 @@ public function testHandleWithAnInvalidSimilarToken()
239239
$listener
240240
->expects($this->once())
241241
->method('getPreAuthenticatedData')
242-
->will($this->returnValue($userCredentials));
242+
->willReturn($userCredentials);
243243

244244
$event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')->disableOriginalConstructor()->getMock();
245245
$event
246246
->expects($this->any())
247247
->method('getRequest')
248-
->will($this->returnValue($request))
248+
->willReturn($request)
249249
;
250250

251251
$listener->handle($event);

0 commit comments

Comments
 (0)