Skip to content

Commit 2362dda

Browse files
committed
Use willReturn() instead of will(returnValue()).
1 parent eebbb6e commit 2362dda

20 files changed

+148
-148
lines changed

Tests/Authentication/AuthenticationProviderManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio
177177
$provider = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface')->getMock();
178178
$provider->expects($this->once())
179179
->method('supports')
180-
->will($this->returnValue($supports))
180+
->willReturn($supports)
181181
;
182182

183183
if (null !== $token) {
184184
$provider->expects($this->once())
185185
->method('authenticate')
186-
->will($this->returnValue($token))
186+
->willReturn($token)
187187
;
188188
} elseif (null !== $exception) {
189189
$provider->expects($this->once())

Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function getSupportedToken($secret)
5858
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\AnonymousToken')->setMethods(['getSecret'])->disableOriginalConstructor()->getMock();
5959
$token->expects($this->any())
6060
->method('getSecret')
61-
->will($this->returnValue($secret))
61+
->willReturn($secret)
6262
;
6363

6464
return $token;

Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testRetrieveUserReturnsUserFromTokenOnReauthentication()
7777
$token = $this->getSupportedToken();
7878
$token->expects($this->once())
7979
->method('getUser')
80-
->will($this->returnValue($user))
80+
->willReturn($user)
8181
;
8282

8383
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
@@ -95,7 +95,7 @@ public function testRetrieveUser()
9595
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
9696
$userProvider->expects($this->once())
9797
->method('loadUserByUsername')
98-
->will($this->returnValue($user))
98+
->willReturn($user)
9999
;
100100

101101
$provider = new DaoAuthenticationProvider($userProvider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface')->getMock(), 'key', $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface')->getMock());
@@ -124,7 +124,7 @@ public function testCheckAuthenticationWhenCredentialsAreEmpty()
124124
$token
125125
->expects($this->once())
126126
->method('getCredentials')
127-
->will($this->returnValue(''))
127+
->willReturn('')
128128
;
129129

130130
$method->invoke(
@@ -140,7 +140,7 @@ public function testCheckAuthenticationWhenCredentialsAre0()
140140
$encoder
141141
->expects($this->once())
142142
->method('isPasswordValid')
143-
->will($this->returnValue(true))
143+
->willReturn(true)
144144
;
145145

146146
$provider = $this->getProvider(null, null, $encoder);
@@ -151,7 +151,7 @@ public function testCheckAuthenticationWhenCredentialsAre0()
151151
$token
152152
->expects($this->once())
153153
->method('getCredentials')
154-
->will($this->returnValue('0'))
154+
->willReturn('0')
155155
;
156156

157157
$method->invoke(
@@ -169,7 +169,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid()
169169
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
170170
$encoder->expects($this->once())
171171
->method('isPasswordValid')
172-
->will($this->returnValue(false))
172+
->willReturn(false)
173173
;
174174

175175
$provider = $this->getProvider(null, null, $encoder);
@@ -179,7 +179,7 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid()
179179
$token = $this->getSupportedToken();
180180
$token->expects($this->once())
181181
->method('getCredentials')
182-
->will($this->returnValue('foo'))
182+
->willReturn('foo')
183183
;
184184

185185
$method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
@@ -193,18 +193,18 @@ public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChang
193193
$user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
194194
$user->expects($this->once())
195195
->method('getPassword')
196-
->will($this->returnValue('foo'))
196+
->willReturn('foo')
197197
;
198198

199199
$token = $this->getSupportedToken();
200200
$token->expects($this->once())
201201
->method('getUser')
202-
->will($this->returnValue($user));
202+
->willReturn($user);
203203

204204
$dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
205205
$dbUser->expects($this->once())
206206
->method('getPassword')
207-
->will($this->returnValue('newFoo'))
207+
->willReturn('newFoo')
208208
;
209209

210210
$provider = $this->getProvider();
@@ -218,18 +218,18 @@ public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithou
218218
$user = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
219219
$user->expects($this->once())
220220
->method('getPassword')
221-
->will($this->returnValue('foo'))
221+
->willReturn('foo')
222222
;
223223

224224
$token = $this->getSupportedToken();
225225
$token->expects($this->once())
226226
->method('getUser')
227-
->will($this->returnValue($user));
227+
->willReturn($user);
228228

229229
$dbUser = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock();
230230
$dbUser->expects($this->once())
231231
->method('getPassword')
232-
->will($this->returnValue('foo'))
232+
->willReturn('foo')
233233
;
234234

235235
$provider = $this->getProvider();
@@ -243,7 +243,7 @@ public function testCheckAuthentication()
243243
$encoder = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface')->getMock();
244244
$encoder->expects($this->once())
245245
->method('isPasswordValid')
246-
->will($this->returnValue(true))
246+
->willReturn(true)
247247
;
248248

249249
$provider = $this->getProvider(null, null, $encoder);
@@ -253,7 +253,7 @@ public function testCheckAuthentication()
253253
$token = $this->getSupportedToken();
254254
$token->expects($this->once())
255255
->method('getCredentials')
256-
->will($this->returnValue('foo'))
256+
->willReturn('foo')
257257
;
258258

259259
$method->invoke($provider, $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserInterface')->getMock(), $token);
@@ -265,7 +265,7 @@ protected function getSupportedToken()
265265
$mock
266266
->expects($this->any())
267267
->method('getProviderKey')
268-
->will($this->returnValue('key'))
268+
->willReturn('key')
269269
;
270270

271271
return $mock;
@@ -277,7 +277,7 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod
277277
if (null !== $user) {
278278
$userProvider->expects($this->once())
279279
->method('loadUserByUsername')
280-
->will($this->returnValue($user))
280+
->willReturn($user)
281281
;
282282
}
283283

@@ -293,7 +293,7 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod
293293
$encoderFactory
294294
->expects($this->any())
295295
->method('getEncoder')
296-
->will($this->returnValue($passwordEncoder))
296+
->willReturn($passwordEncoder)
297297
;
298298

299299
return new DaoAuthenticationProvider($userProvider, $userChecker, 'key', $encoderFactory);

Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,21 @@ public function testQueryForDn()
113113
$query
114114
->expects($this->once())
115115
->method('execute')
116-
->will($this->returnValue($collection))
116+
->willReturn($collection)
117117
;
118118

119119
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
120120
$ldap
121121
->expects($this->once())
122122
->method('escape')
123123
->with('foo', '')
124-
->will($this->returnValue('foo'))
124+
->willReturn('foo')
125125
;
126126
$ldap
127127
->expects($this->once())
128128
->method('query')
129129
->with('{username}', 'foobar')
130-
->will($this->returnValue($query))
130+
->willReturn($query)
131131
;
132132
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
133133

@@ -153,14 +153,14 @@ public function testEmptyQueryResultShouldThrowAnException()
153153
$query
154154
->expects($this->once())
155155
->method('execute')
156-
->will($this->returnValue($collection))
156+
->willReturn($collection)
157157
;
158158

159159
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
160160
$ldap
161161
->expects($this->once())
162162
->method('query')
163-
->will($this->returnValue($query))
163+
->willReturn($query)
164164
;
165165
$userChecker = $this->getMockBuilder(UserCheckerInterface::class)->getMock();
166166

Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testSupports()
3131
$token
3232
->expects($this->once())
3333
->method('getProviderKey')
34-
->will($this->returnValue('foo'))
34+
->willReturn('foo')
3535
;
3636
$this->assertFalse($provider->supports($token));
3737
}
@@ -62,7 +62,7 @@ public function testAuthenticate()
6262
$user
6363
->expects($this->once())
6464
->method('getRoles')
65-
->will($this->returnValue([]))
65+
->willReturn([])
6666
;
6767
$provider = $this->getProvider($user);
6868

@@ -99,20 +99,20 @@ protected function getSupportedToken($user = false, $credentials = false)
9999
if (false !== $user) {
100100
$token->expects($this->once())
101101
->method('getUser')
102-
->will($this->returnValue($user))
102+
->willReturn($user)
103103
;
104104
}
105105
if (false !== $credentials) {
106106
$token->expects($this->once())
107107
->method('getCredentials')
108-
->will($this->returnValue($credentials))
108+
->willReturn($credentials)
109109
;
110110
}
111111

112112
$token
113113
->expects($this->any())
114114
->method('getProviderKey')
115-
->will($this->returnValue('key'))
115+
->willReturn('key')
116116
;
117117

118118
$token->setAttributes(['foo' => 'bar']);
@@ -126,7 +126,7 @@ protected function getProvider($user = null, $userChecker = null)
126126
if (null !== $user) {
127127
$userProvider->expects($this->once())
128128
->method('loadUserByUsername')
129-
->will($this->returnValue($user))
129+
->willReturn($user)
130130
;
131131
}
132132

Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function testAuthenticate()
6969
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
7070
$user->expects($this->exactly(2))
7171
->method('getRoles')
72-
->will($this->returnValue(['ROLE_FOO']));
72+
->willReturn(['ROLE_FOO']);
7373

7474
$provider = $this->getProvider();
7575

@@ -89,14 +89,14 @@ protected function getSupportedToken($user = null, $secret = 'test')
8989
$user
9090
->expects($this->any())
9191
->method('getRoles')
92-
->will($this->returnValue([]));
92+
->willReturn([]);
9393
}
9494

9595
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\RememberMeToken')->setMethods(['getProviderKey'])->setConstructorArgs([$user, 'foo', $secret])->getMock();
9696
$token
9797
->expects($this->once())
9898
->method('getProviderKey')
99-
->will($this->returnValue('foo'));
99+
->willReturn('foo');
100100

101101
return $token;
102102
}

Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testAuthenticateWhenPreChecksFails()
2929
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
3030
$token->expects($this->any())
3131
->method('getUser')
32-
->will($this->returnValue($user));
32+
->willReturn($user);
3333

3434
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
3535
$userChecker->expects($this->once())
@@ -39,7 +39,7 @@ public function testAuthenticateWhenPreChecksFails()
3939
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
4040
$authenticator->expects($this->once())
4141
->method('authenticateToken')
42-
->will($this->returnValue($token));
42+
->willReturn($token);
4343

4444
$provider = $this->getProvider($authenticator, null, $userChecker);
4545

@@ -56,7 +56,7 @@ public function testAuthenticateWhenPostChecksFails()
5656
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
5757
$token->expects($this->any())
5858
->method('getUser')
59-
->will($this->returnValue($user));
59+
->willReturn($user);
6060

6161
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
6262
$userChecker->expects($this->once())
@@ -66,7 +66,7 @@ public function testAuthenticateWhenPostChecksFails()
6666
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
6767
$authenticator->expects($this->once())
6868
->method('authenticateToken')
69-
->will($this->returnValue($token));
69+
->willReturn($token);
7070

7171
$provider = $this->getProvider($authenticator, null, $userChecker);
7272

@@ -78,11 +78,11 @@ public function testAuthenticateSkipsUserChecksForNonUserInterfaceObjects()
7878
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
7979
$token->expects($this->any())
8080
->method('getUser')
81-
->will($this->returnValue('string-user'));
81+
->willReturn('string-user');
8282
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
8383
$authenticator->expects($this->once())
8484
->method('authenticateToken')
85-
->will($this->returnValue($token));
85+
->willReturn($token);
8686

8787
$this->assertSame($token, $this->getProvider($authenticator, null, new UserChecker())->authenticate($token));
8888
}

0 commit comments

Comments
 (0)