@@ -24,20 +24,20 @@ class ChainUserProviderTest extends TestCase
2424{
2525 public function testLoadUserByUsername ()
2626 {
27- $ provider1 = $ this ->getProvider ( );
27+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
2828 $ provider1
2929 ->expects ($ this ->once ())
3030 ->method ('loadUserByUsername ' )
3131 ->with ($ this ->equalTo ('foo ' ))
3232 ->willThrowException (new UsernameNotFoundException ('not found ' ))
3333 ;
3434
35- $ provider2 = $ this ->getProvider ( );
35+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
3636 $ provider2
3737 ->expects ($ this ->once ())
3838 ->method ('loadUserByUsername ' )
3939 ->with ($ this ->equalTo ('foo ' ))
40- ->willReturn ($ account = $ this ->getAccount ( ))
40+ ->willReturn ($ account = $ this ->createMock (UserInterface::class ))
4141 ;
4242
4343 $ provider = new ChainUserProvider ([$ provider1 , $ provider2 ]);
@@ -47,15 +47,15 @@ public function testLoadUserByUsername()
4747 public function testLoadUserByUsernameThrowsUsernameNotFoundException ()
4848 {
4949 $ this ->expectException (UsernameNotFoundException::class);
50- $ provider1 = $ this ->getProvider ( );
50+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
5151 $ provider1
5252 ->expects ($ this ->once ())
5353 ->method ('loadUserByUsername ' )
5454 ->with ($ this ->equalTo ('foo ' ))
5555 ->willThrowException (new UsernameNotFoundException ('not found ' ))
5656 ;
5757
58- $ provider2 = $ this ->getProvider ( );
58+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
5959 $ provider2
6060 ->expects ($ this ->once ())
6161 ->method ('loadUserByUsername ' )
@@ -69,14 +69,14 @@ public function testLoadUserByUsernameThrowsUsernameNotFoundException()
6969
7070 public function testRefreshUser ()
7171 {
72- $ provider1 = $ this ->getProvider ( );
72+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
7373 $ provider1
7474 ->expects ($ this ->once ())
7575 ->method ('supportsClass ' )
7676 ->willReturn (false )
7777 ;
7878
79- $ provider2 = $ this ->getProvider ( );
79+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
8080 $ provider2
8181 ->expects ($ this ->once ())
8282 ->method ('supportsClass ' )
@@ -89,7 +89,7 @@ public function testRefreshUser()
8989 ->willThrowException (new UnsupportedUserException ('unsupported ' ))
9090 ;
9191
92- $ provider3 = $ this ->getProvider ( );
92+ $ provider3 = $ this ->createMock (UserProviderInterface::class );
9393 $ provider3
9494 ->expects ($ this ->once ())
9595 ->method ('supportsClass ' )
@@ -99,16 +99,16 @@ public function testRefreshUser()
9999 $ provider3
100100 ->expects ($ this ->once ())
101101 ->method ('refreshUser ' )
102- ->willReturn ($ account = $ this ->getAccount ( ))
102+ ->willReturn ($ account = $ this ->createMock (UserInterface::class ))
103103 ;
104104
105105 $ provider = new ChainUserProvider ([$ provider1 , $ provider2 , $ provider3 ]);
106- $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->getAccount ( )));
106+ $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->createMock (UserInterface::class )));
107107 }
108108
109109 public function testRefreshUserAgain ()
110110 {
111- $ provider1 = $ this ->getProvider ( );
111+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
112112 $ provider1
113113 ->expects ($ this ->once ())
114114 ->method ('supportsClass ' )
@@ -121,7 +121,7 @@ public function testRefreshUserAgain()
121121 ->willThrowException (new UsernameNotFoundException ('not found ' ))
122122 ;
123123
124- $ provider2 = $ this ->getProvider ( );
124+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
125125 $ provider2
126126 ->expects ($ this ->once ())
127127 ->method ('supportsClass ' )
@@ -131,17 +131,17 @@ public function testRefreshUserAgain()
131131 $ provider2
132132 ->expects ($ this ->once ())
133133 ->method ('refreshUser ' )
134- ->willReturn ($ account = $ this ->getAccount ( ))
134+ ->willReturn ($ account = $ this ->createMock (UserInterface::class ))
135135 ;
136136
137137 $ provider = new ChainUserProvider ([$ provider1 , $ provider2 ]);
138- $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->getAccount ( )));
138+ $ this ->assertSame ($ account , $ provider ->refreshUser ($ this ->createMock (UserInterface::class )));
139139 }
140140
141141 public function testRefreshUserThrowsUnsupportedUserException ()
142142 {
143143 $ this ->expectException (UnsupportedUserException::class);
144- $ provider1 = $ this ->getProvider ( );
144+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
145145 $ provider1
146146 ->expects ($ this ->once ())
147147 ->method ('supportsClass ' )
@@ -154,7 +154,7 @@ public function testRefreshUserThrowsUnsupportedUserException()
154154 ->willThrowException (new UnsupportedUserException ('unsupported ' ))
155155 ;
156156
157- $ provider2 = $ this ->getProvider ( );
157+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
158158 $ provider2
159159 ->expects ($ this ->once ())
160160 ->method ('supportsClass ' )
@@ -168,20 +168,20 @@ public function testRefreshUserThrowsUnsupportedUserException()
168168 ;
169169
170170 $ provider = new ChainUserProvider ([$ provider1 , $ provider2 ]);
171- $ provider ->refreshUser ($ this ->getAccount ( ));
171+ $ provider ->refreshUser ($ this ->createMock (UserInterface::class ));
172172 }
173173
174174 public function testSupportsClass ()
175175 {
176- $ provider1 = $ this ->getProvider ( );
176+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
177177 $ provider1
178178 ->expects ($ this ->once ())
179179 ->method ('supportsClass ' )
180180 ->with ($ this ->equalTo ('foo ' ))
181181 ->willReturn (false )
182182 ;
183183
184- $ provider2 = $ this ->getProvider ( );
184+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
185185 $ provider2
186186 ->expects ($ this ->once ())
187187 ->method ('supportsClass ' )
@@ -195,15 +195,15 @@ public function testSupportsClass()
195195
196196 public function testSupportsClassWhenNotSupported ()
197197 {
198- $ provider1 = $ this ->getProvider ( );
198+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
199199 $ provider1
200200 ->expects ($ this ->once ())
201201 ->method ('supportsClass ' )
202202 ->with ($ this ->equalTo ('foo ' ))
203203 ->willReturn (false )
204204 ;
205205
206- $ provider2 = $ this ->getProvider ( );
206+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
207207 $ provider2
208208 ->expects ($ this ->once ())
209209 ->method ('supportsClass ' )
@@ -217,7 +217,7 @@ public function testSupportsClassWhenNotSupported()
217217
218218 public function testAcceptsTraversable ()
219219 {
220- $ provider1 = $ this ->getProvider ( );
220+ $ provider1 = $ this ->createMock (UserProviderInterface::class );
221221 $ provider1
222222 ->expects ($ this ->once ())
223223 ->method ('supportsClass ' )
@@ -230,7 +230,7 @@ public function testAcceptsTraversable()
230230 ->willThrowException (new UnsupportedUserException ('unsupported ' ))
231231 ;
232232
233- $ provider2 = $ this ->getProvider ( );
233+ $ provider2 = $ this ->createMock (UserProviderInterface::class );
234234 $ provider2
235235 ->expects ($ this ->once ())
236236 ->method ('supportsClass ' )
@@ -240,11 +240,11 @@ public function testAcceptsTraversable()
240240 $ provider2
241241 ->expects ($ this ->once ())
242242 ->method ('refreshUser ' )
243- ->willReturn ($ account = $ this ->getAccount ( ))
243+ ->willReturn ($ account = $ this ->createMock (UserInterface::class ))
244244 ;
245245
246246 $ 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 )));
248248 }
249249
250250 public function testPasswordUpgrades ()
@@ -268,14 +268,4 @@ public function testPasswordUpgrades()
268268 $ provider = new ChainUserProvider ([$ provider1 , $ provider2 ]);
269269 $ provider ->upgradePassword ($ user , 'foobar ' );
270270 }
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- }
281271}
0 commit comments