@@ -24,20 +24,20 @@ class ChainUserProviderTest extends TestCase
24
24
{
25
25
public function testLoadUserByUsername ()
26
26
{
27
- $ provider1 = $ this ->getProvider ( );
27
+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
28
28
$ provider1
29
29
->expects ($ this ->once ())
30
30
->method ('loadUserByUsername ' )
31
31
->with ($ this ->equalTo ('foo ' ))
32
32
->willThrowException (new UsernameNotFoundException ('not found ' ))
33
33
;
34
34
35
- $ provider2 = $ this ->getProvider ( );
35
+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
36
36
$ provider2
37
37
->expects ($ this ->once ())
38
38
->method ('loadUserByUsername ' )
39
39
->with ($ this ->equalTo ('foo ' ))
40
- ->willReturn ($ account = $ this ->getAccount ( ))
40
+ ->willReturn ($ account = $ this ->createMock (UserInterface::class ))
41
41
;
42
42
43
43
$ provider = new ChainUserProvider ([$ provider1 , $ provider2 ]);
@@ -47,15 +47,15 @@ public function testLoadUserByUsername()
47
47
public function testLoadUserByUsernameThrowsUsernameNotFoundException ()
48
48
{
49
49
$ this ->expectException (UsernameNotFoundException::class);
50
- $ provider1 = $ this ->getProvider ( );
50
+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
51
51
$ provider1
52
52
->expects ($ this ->once ())
53
53
->method ('loadUserByUsername ' )
54
54
->with ($ this ->equalTo ('foo ' ))
55
55
->willThrowException (new UsernameNotFoundException ('not found ' ))
56
56
;
57
57
58
- $ provider2 = $ this ->getProvider ( );
58
+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
59
59
$ provider2
60
60
->expects ($ this ->once ())
61
61
->method ('loadUserByUsername ' )
@@ -69,14 +69,14 @@ public function testLoadUserByUsernameThrowsUsernameNotFoundException()
69
69
70
70
public function testRefreshUser ()
71
71
{
72
- $ provider1 = $ this ->getProvider ( );
72
+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
73
73
$ provider1
74
74
->expects ($ this ->once ())
75
75
->method ('supportsClass ' )
76
76
->willReturn (false )
77
77
;
78
78
79
- $ provider2 = $ this ->getProvider ( );
79
+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
80
80
$ provider2
81
81
->expects ($ this ->once ())
82
82
->method ('supportsClass ' )
@@ -89,7 +89,7 @@ public function testRefreshUser()
89
89
->willThrowException (new UnsupportedUserException ('unsupported ' ))
90
90
;
91
91
92
- $ provider3 = $ this ->getProvider ( );
92
+ $ provider3 = $ this ->createMock (UserProviderInterface::class );
93
93
$ provider3
94
94
->expects ($ this ->once ())
95
95
->method ('supportsClass ' )
@@ -99,16 +99,16 @@ public function testRefreshUser()
99
99
$ provider3
100
100
->expects ($ this ->once ())
101
101
->method ('refreshUser ' )
102
- ->willReturn ($ account = $ this ->getAccount ( ))
102
+ ->willReturn ($ account = $ this ->createMock (UserInterface::class ))
103
103
;
104
104
105
105
$ provider = new ChainUserProvider ([$ provider1 , $ provider2 , $ provider3 ]);
106
- $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->getAccount ( )));
106
+ $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->createMock (UserInterface::class )));
107
107
}
108
108
109
109
public function testRefreshUserAgain ()
110
110
{
111
- $ provider1 = $ this ->getProvider ( );
111
+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
112
112
$ provider1
113
113
->expects ($ this ->once ())
114
114
->method ('supportsClass ' )
@@ -121,7 +121,7 @@ public function testRefreshUserAgain()
121
121
->willThrowException (new UsernameNotFoundException ('not found ' ))
122
122
;
123
123
124
- $ provider2 = $ this ->getProvider ( );
124
+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
125
125
$ provider2
126
126
->expects ($ this ->once ())
127
127
->method ('supportsClass ' )
@@ -131,17 +131,17 @@ public function testRefreshUserAgain()
131
131
$ provider2
132
132
->expects ($ this ->once ())
133
133
->method ('refreshUser ' )
134
- ->willReturn ($ account = $ this ->getAccount ( ))
134
+ ->willReturn ($ account = $ this ->createMock (UserInterface::class ))
135
135
;
136
136
137
137
$ provider = new ChainUserProvider ([$ provider1 , $ provider2 ]);
138
- $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->getAccount ( )));
138
+ $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->createMock (UserInterface::class )));
139
139
}
140
140
141
141
public function testRefreshUserThrowsUnsupportedUserException ()
142
142
{
143
143
$ this ->expectException (UnsupportedUserException::class);
144
- $ provider1 = $ this ->getProvider ( );
144
+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
145
145
$ provider1
146
146
->expects ($ this ->once ())
147
147
->method ('supportsClass ' )
@@ -154,7 +154,7 @@ public function testRefreshUserThrowsUnsupportedUserException()
154
154
->willThrowException (new UnsupportedUserException ('unsupported ' ))
155
155
;
156
156
157
- $ provider2 = $ this ->getProvider ( );
157
+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
158
158
$ provider2
159
159
->expects ($ this ->once ())
160
160
->method ('supportsClass ' )
@@ -168,20 +168,20 @@ public function testRefreshUserThrowsUnsupportedUserException()
168
168
;
169
169
170
170
$ provider = new ChainUserProvider ([$ provider1 , $ provider2 ]);
171
- $ provider ->refreshUser ($ this ->getAccount ( ));
171
+ $ provider ->refreshUser ($ this ->createMock (UserInterface::class ));
172
172
}
173
173
174
174
public function testSupportsClass ()
175
175
{
176
- $ provider1 = $ this ->getProvider ( );
176
+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
177
177
$ provider1
178
178
->expects ($ this ->once ())
179
179
->method ('supportsClass ' )
180
180
->with ($ this ->equalTo ('foo ' ))
181
181
->willReturn (false )
182
182
;
183
183
184
- $ provider2 = $ this ->getProvider ( );
184
+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
185
185
$ provider2
186
186
->expects ($ this ->once ())
187
187
->method ('supportsClass ' )
@@ -195,15 +195,15 @@ public function testSupportsClass()
195
195
196
196
public function testSupportsClassWhenNotSupported ()
197
197
{
198
- $ provider1 = $ this ->getProvider ( );
198
+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
199
199
$ provider1
200
200
->expects ($ this ->once ())
201
201
->method ('supportsClass ' )
202
202
->with ($ this ->equalTo ('foo ' ))
203
203
->willReturn (false )
204
204
;
205
205
206
- $ provider2 = $ this ->getProvider ( );
206
+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
207
207
$ provider2
208
208
->expects ($ this ->once ())
209
209
->method ('supportsClass ' )
@@ -217,7 +217,7 @@ public function testSupportsClassWhenNotSupported()
217
217
218
218
public function testAcceptsTraversable ()
219
219
{
220
- $ provider1 = $ this ->getProvider ( );
220
+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
221
221
$ provider1
222
222
->expects ($ this ->once ())
223
223
->method ('supportsClass ' )
@@ -230,7 +230,7 @@ public function testAcceptsTraversable()
230
230
->willThrowException (new UnsupportedUserException ('unsupported ' ))
231
231
;
232
232
233
- $ provider2 = $ this ->getProvider ( );
233
+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
234
234
$ provider2
235
235
->expects ($ this ->once ())
236
236
->method ('supportsClass ' )
@@ -240,11 +240,11 @@ public function testAcceptsTraversable()
240
240
$ provider2
241
241
->expects ($ this ->once ())
242
242
->method ('refreshUser ' )
243
- ->willReturn ($ account = $ this ->getAccount ( ))
243
+ ->willReturn ($ account = $ this ->createMock (UserInterface::class ))
244
244
;
245
245
246
246
$ provider = new ChainUserProvider (new \ArrayObject ([$ provider1 , $ provider2 ]));
247
- $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->getAccount ( )));
247
+ $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->createMock (UserInterface::class )));
248
248
}
249
249
250
250
public function testPasswordUpgrades ()
@@ -268,14 +268,4 @@ public function testPasswordUpgrades()
268
268
$ provider = new ChainUserProvider ([$ provider1 , $ provider2 ]);
269
269
$ provider ->upgradePassword ($ user , 'foobar ' );
270
270
}
271
-
272
- protected function getAccount ()
273
- {
274
- return $ this ->createMock (UserInterface::class);
275
- }
276
-
277
- protected function getProvider ()
278
- {
279
- return $ this ->createMock (UserProviderInterface::class);
280
- }
281
271
}
0 commit comments