@@ -34,13 +34,13 @@ public function testRetrieveUserWhenProviderDoesNotReturnAnUserInterface()
34
34
*/
35
35
public function testRetrieveUserWhenUsernameIsNotFound ()
36
36
{
37
- $ userProvider = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' );
37
+ $ userProvider = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' )-> getMock ( );
38
38
$ userProvider ->expects ($ this ->once ())
39
39
->method ('loadUserByUsername ' )
40
40
->will ($ this ->throwException (new UsernameNotFoundException ()))
41
41
;
42
42
43
- $ provider = new DaoAuthenticationProvider ($ userProvider , $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' ), 'key ' , $ this ->getMock ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' ));
43
+ $ provider = new DaoAuthenticationProvider ($ userProvider , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' )-> getMock () , 'key ' , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' )-> getMock ( ));
44
44
$ method = new \ReflectionMethod ($ provider , 'retrieveUser ' );
45
45
$ method ->setAccessible (true );
46
46
@@ -52,13 +52,13 @@ public function testRetrieveUserWhenUsernameIsNotFound()
52
52
*/
53
53
public function testRetrieveUserWhenAnExceptionOccurs ()
54
54
{
55
- $ userProvider = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' );
55
+ $ userProvider = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' )-> getMock ( );
56
56
$ userProvider ->expects ($ this ->once ())
57
57
->method ('loadUserByUsername ' )
58
58
->will ($ this ->throwException (new \RuntimeException ()))
59
59
;
60
60
61
- $ provider = new DaoAuthenticationProvider ($ userProvider , $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' ), 'key ' , $ this ->getMock ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' ));
61
+ $ provider = new DaoAuthenticationProvider ($ userProvider , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' )-> getMock () , 'key ' , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' )-> getMock ( ));
62
62
$ method = new \ReflectionMethod ($ provider , 'retrieveUser ' );
63
63
$ method ->setAccessible (true );
64
64
@@ -67,19 +67,19 @@ public function testRetrieveUserWhenAnExceptionOccurs()
67
67
68
68
public function testRetrieveUserReturnsUserFromTokenOnReauthentication ()
69
69
{
70
- $ userProvider = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' );
70
+ $ userProvider = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' )-> getMock ( );
71
71
$ userProvider ->expects ($ this ->never ())
72
72
->method ('loadUserByUsername ' )
73
73
;
74
74
75
- $ user = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' );
75
+ $ user = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( );
76
76
$ token = $ this ->getSupportedToken ();
77
77
$ token ->expects ($ this ->once ())
78
78
->method ('getUser ' )
79
79
->will ($ this ->returnValue ($ user ))
80
80
;
81
81
82
- $ provider = new DaoAuthenticationProvider ($ userProvider , $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' ), 'key ' , $ this ->getMock ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' ));
82
+ $ provider = new DaoAuthenticationProvider ($ userProvider , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' )-> getMock () , 'key ' , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' )-> getMock ( ));
83
83
$ reflection = new \ReflectionMethod ($ provider , 'retrieveUser ' );
84
84
$ reflection ->setAccessible (true );
85
85
$ result = $ reflection ->invoke ($ provider , null , $ token );
@@ -89,15 +89,15 @@ public function testRetrieveUserReturnsUserFromTokenOnReauthentication()
89
89
90
90
public function testRetrieveUser ()
91
91
{
92
- $ user = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' );
92
+ $ user = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( );
93
93
94
- $ userProvider = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' );
94
+ $ userProvider = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' )-> getMock ( );
95
95
$ userProvider ->expects ($ this ->once ())
96
96
->method ('loadUserByUsername ' )
97
97
->will ($ this ->returnValue ($ user ))
98
98
;
99
99
100
- $ provider = new DaoAuthenticationProvider ($ userProvider , $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' ), 'key ' , $ this ->getMock ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' ));
100
+ $ provider = new DaoAuthenticationProvider ($ userProvider , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' )-> getMock () , 'key ' , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' )-> getMock ( ));
101
101
$ method = new \ReflectionMethod ($ provider , 'retrieveUser ' );
102
102
$ method ->setAccessible (true );
103
103
@@ -109,7 +109,7 @@ public function testRetrieveUser()
109
109
*/
110
110
public function testCheckAuthenticationWhenCredentialsAreEmpty ()
111
111
{
112
- $ encoder = $ this ->getMock ('Symfony \\Component \\Security \\Core \\Encoder \\PasswordEncoderInterface ' );
112
+ $ encoder = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Encoder \\PasswordEncoderInterface ' )-> getMock ( );
113
113
$ encoder
114
114
->expects ($ this ->never ())
115
115
->method ('isPasswordValid ' )
@@ -128,14 +128,14 @@ public function testCheckAuthenticationWhenCredentialsAreEmpty()
128
128
129
129
$ method ->invoke (
130
130
$ provider ,
131
- $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' ),
131
+ $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( ),
132
132
$ token
133
133
);
134
134
}
135
135
136
136
public function testCheckAuthenticationWhenCredentialsAre0 ()
137
137
{
138
- $ encoder = $ this ->getMock ('Symfony \\Component \\Security \\Core \\Encoder \\PasswordEncoderInterface ' );
138
+ $ encoder = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Encoder \\PasswordEncoderInterface ' )-> getMock ( );
139
139
$ encoder
140
140
->expects ($ this ->once ())
141
141
->method ('isPasswordValid ' )
@@ -155,7 +155,7 @@ public function testCheckAuthenticationWhenCredentialsAre0()
155
155
156
156
$ method ->invoke (
157
157
$ provider ,
158
- $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' ),
158
+ $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( ),
159
159
$ token
160
160
);
161
161
}
@@ -165,7 +165,7 @@ public function testCheckAuthenticationWhenCredentialsAre0()
165
165
*/
166
166
public function testCheckAuthenticationWhenCredentialsAreNotValid ()
167
167
{
168
- $ encoder = $ this ->getMock ('Symfony \\Component \\Security \\Core \\Encoder \\PasswordEncoderInterface ' );
168
+ $ encoder = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Encoder \\PasswordEncoderInterface ' )-> getMock ( );
169
169
$ encoder ->expects ($ this ->once ())
170
170
->method ('isPasswordValid ' )
171
171
->will ($ this ->returnValue (false ))
@@ -181,15 +181,15 @@ public function testCheckAuthenticationWhenCredentialsAreNotValid()
181
181
->will ($ this ->returnValue ('foo ' ))
182
182
;
183
183
184
- $ method ->invoke ($ provider , $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' ), $ token );
184
+ $ method ->invoke ($ provider , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( ), $ token );
185
185
}
186
186
187
187
/**
188
188
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
189
189
*/
190
190
public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChanged ()
191
191
{
192
- $ user = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' );
192
+ $ user = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( );
193
193
$ user ->expects ($ this ->once ())
194
194
->method ('getPassword ' )
195
195
->will ($ this ->returnValue ('foo ' ))
@@ -200,7 +200,7 @@ public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChang
200
200
->method ('getUser ' )
201
201
->will ($ this ->returnValue ($ user ));
202
202
203
- $ dbUser = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' );
203
+ $ dbUser = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( );
204
204
$ dbUser ->expects ($ this ->once ())
205
205
->method ('getPassword ' )
206
206
->will ($ this ->returnValue ('newFoo ' ))
@@ -214,7 +214,7 @@ public function testCheckAuthenticationDoesNotReauthenticateWhenPasswordHasChang
214
214
215
215
public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithoutOriginalCredentials ()
216
216
{
217
- $ user = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' );
217
+ $ user = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( );
218
218
$ user ->expects ($ this ->once ())
219
219
->method ('getPassword ' )
220
220
->will ($ this ->returnValue ('foo ' ))
@@ -225,7 +225,7 @@ public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithou
225
225
->method ('getUser ' )
226
226
->will ($ this ->returnValue ($ user ));
227
227
228
- $ dbUser = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' );
228
+ $ dbUser = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( );
229
229
$ dbUser ->expects ($ this ->once ())
230
230
->method ('getPassword ' )
231
231
->will ($ this ->returnValue ('foo ' ))
@@ -239,7 +239,7 @@ public function testCheckAuthenticationWhenTokenNeedsReauthenticationWorksWithou
239
239
240
240
public function testCheckAuthentication ()
241
241
{
242
- $ encoder = $ this ->getMock ('Symfony \\Component \\Security \\Core \\Encoder \\PasswordEncoderInterface ' );
242
+ $ encoder = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Encoder \\PasswordEncoderInterface ' )-> getMock ( );
243
243
$ encoder ->expects ($ this ->once ())
244
244
->method ('isPasswordValid ' )
245
245
->will ($ this ->returnValue (true ))
@@ -255,12 +255,12 @@ public function testCheckAuthentication()
255
255
->will ($ this ->returnValue ('foo ' ))
256
256
;
257
257
258
- $ method ->invoke ($ provider , $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' ), $ token );
258
+ $ method ->invoke ($ provider , $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserInterface ' )-> getMock ( ), $ token );
259
259
}
260
260
261
261
protected function getSupportedToken ()
262
262
{
263
- $ mock = $ this ->getMock ('Symfony \\Component \\Security \\Core \\Authentication \\Token \\UsernamePasswordToken ' , array ('getCredentials ' , 'getUser ' , 'getProviderKey ' ), array (), '' , false );
263
+ $ mock = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Authentication \\Token \\UsernamePasswordToken ' )-> setMethods ( array ('getCredentials ' , 'getUser ' , 'getProviderKey ' ))-> disableOriginalConstructor ()-> getMock ( );
264
264
$ mock
265
265
->expects ($ this ->any ())
266
266
->method ('getProviderKey ' )
@@ -272,7 +272,7 @@ protected function getSupportedToken()
272
272
273
273
protected function getProvider ($ user = null , $ userChecker = null , $ passwordEncoder = null )
274
274
{
275
- $ userProvider = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' );
275
+ $ userProvider = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserProviderInterface ' )-> getMock ( );
276
276
if (null !== $ user ) {
277
277
$ userProvider ->expects ($ this ->once ())
278
278
->method ('loadUserByUsername ' )
@@ -281,14 +281,14 @@ protected function getProvider($user = null, $userChecker = null, $passwordEncod
281
281
}
282
282
283
283
if (null === $ userChecker ) {
284
- $ userChecker = $ this ->getMock ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' );
284
+ $ userChecker = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\User \\UserCheckerInterface ' )-> getMock ( );
285
285
}
286
286
287
287
if (null === $ passwordEncoder ) {
288
288
$ passwordEncoder = new PlaintextPasswordEncoder ();
289
289
}
290
290
291
- $ encoderFactory = $ this ->getMock ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' );
291
+ $ encoderFactory = $ this ->getMockBuilder ('Symfony \\Component \\Security \\Core \\Encoder \\EncoderFactoryInterface ' )-> getMock ( );
292
292
$ encoderFactory
293
293
->expects ($ this ->any ())
294
294
->method ('getEncoder ' )
0 commit comments