@@ -66,12 +66,12 @@ public function setUp()
6666 Security::salt ('YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi ' );
6767 Configure::write ('App.namespace ' , 'Users ' );
6868 $ this ->request = $ this ->getMockBuilder ('Cake\Network\Request ' )
69- ->setMethods (['is ' , 'method ' ])
70- ->getMock ();
69+ ->setMethods (['is ' , 'method ' ])
70+ ->getMock ();
7171 $ this ->request ->expects ($ this ->any ())->method ('is ' )->will ($ this ->returnValue (true ));
7272 $ this ->response = $ this ->getMockBuilder ('Cake\Network\Response ' )
73- ->setMethods (['stop ' ])
74- ->getMock ();
73+ ->setMethods (['stop ' ])
74+ ->getMock ();
7575 $ this ->Controller = new Controller ($ this ->request , $ this ->response );
7676 $ this ->Registry = $ this ->Controller ->components ();
7777 $ this ->Controller ->UsersAuth = new UsersAuthComponent ($ this ->Registry );
@@ -111,13 +111,13 @@ public function testInitializeNoRequiredRememberMe()
111111 Configure::write ('Users.RememberMe.active ' , false );
112112 $ class = 'CakeDC\Users\Controller\Component\UsersAuthComponent ' ;
113113 $ this ->Controller ->UsersAuth = $ this ->getMockBuilder ($ class )
114- ->setMethods (['_loadRememberMe ' , '_initAuth ' , '_loadSocialLogin ' , '_attachPermissionChecker ' ])
115- ->disableOriginalConstructor ()
116- ->getMock ();
114+ ->setMethods (['_loadRememberMe ' , '_initAuth ' , '_loadSocialLogin ' , '_attachPermissionChecker ' ])
115+ ->disableOriginalConstructor ()
116+ ->getMock ();
117117 $ this ->Controller ->UsersAuth ->expects ($ this ->once ())
118- ->method ('_initAuth ' );
118+ ->method ('_initAuth ' );
119119 $ this ->Controller ->UsersAuth ->expects ($ this ->never ())
120- ->method ('_loadRememberMe ' );
120+ ->method ('_loadRememberMe ' );
121121 $ this ->Controller ->UsersAuth ->initialize ([]);
122122 }
123123
@@ -133,12 +133,12 @@ public function testIsUrlAuthorizedUserNotLoggedIn()
133133 'url ' => '/route ' ,
134134 ];
135135 $ this ->Controller ->Auth = $ this ->getMockBuilder ('Cake\Controller\Component\AuthComponent ' )
136- ->setMethods (['user ' , 'isAuthorized ' ])
137- ->disableOriginalConstructor ()
138- ->getMock ();
136+ ->setMethods (['user ' , 'isAuthorized ' ])
137+ ->disableOriginalConstructor ()
138+ ->getMock ();
139139 $ this ->Controller ->Auth ->expects ($ this ->once ())
140- ->method ('user ' )
141- ->will ($ this ->returnValue (false ));
140+ ->method ('user ' )
141+ ->will ($ this ->returnValue (false ));
142142 $ result = $ this ->Controller ->UsersAuth ->isUrlAuthorized ($ event );
143143 $ this ->assertFalse ($ result );
144144 }
@@ -220,9 +220,9 @@ public function testIsUrlAuthorizedNoUrl()
220220 {
221221 $ event = new Event ('event ' );
222222 $ this ->Controller ->Auth = $ this ->getMockBuilder ('Cake\Controller\Component\AuthComponent ' )
223- ->setMethods (['user ' , 'isAuthorized ' ])
224- ->disableOriginalConstructor ()
225- ->getMock ();
223+ ->setMethods (['user ' , 'isAuthorized ' ])
224+ ->disableOriginalConstructor ()
225+ ->getMock ();
226226 $ result = $ this ->Controller ->UsersAuth ->isUrlAuthorized ($ event );
227227 $ this ->assertFalse ($ result );
228228 }
@@ -239,24 +239,24 @@ public function testIsUrlAuthorizedUrlRelativeString()
239239 'url ' => '/route ' ,
240240 ];
241241 $ this ->Controller ->Auth = $ this ->getMockBuilder ('Cake\Controller\Component\AuthComponent ' )
242- ->setMethods (['user ' , 'isAuthorized ' ])
243- ->disableOriginalConstructor ()
244- ->getMock ();
242+ ->setMethods (['user ' , 'isAuthorized ' ])
243+ ->disableOriginalConstructor ()
244+ ->getMock ();
245245 $ this ->Controller ->Auth ->expects ($ this ->once ())
246- ->method ('user ' )
247- ->will ($ this ->returnValue (['id ' => 1 ]));
248- $ request = new Request ('/route ' );
249- $ request ->params = [
250- 'plugin ' => 'CakeDC/Users ' ,
251- 'controller ' => 'Users ' ,
252- 'action ' => 'requestResetPassword ' ,
253- 'pass ' => [],
254- '_matchedRoute ' => '/route/* ' ,
255- ];
246+ ->method ('user ' )
247+ ->will ($ this ->returnValue (['id ' => 1 ]));
256248 $ this ->Controller ->Auth ->expects ($ this ->once ())
257- ->method ('isAuthorized ' )
258- ->with (null , $ request )
259- ->will ($ this ->returnValue (true ));
249+ ->method ('isAuthorized ' )
250+ ->with (null , $ this ->callback (function ($ subject ) {
251+ return $ subject ->params === [
252+ 'pass ' => [],
253+ 'plugin ' => 'CakeDC/Users ' ,
254+ 'controller ' => 'Users ' ,
255+ 'action ' => 'requestResetPassword ' ,
256+ '_matchedRoute ' => '/route/* ' ,
257+ ];
258+ }))
259+ ->will ($ this ->returnValue (true ));
260260 $ result = $ this ->Controller ->UsersAuth ->isUrlAuthorized ($ event );
261261 $ this ->assertTrue ($ result );
262262 }
@@ -274,11 +274,11 @@ public function testIsUrlAuthorizedMissingRouteString()
274274 'url ' => '/missingRoute ' ,
275275 ];
276276 $ this ->Controller ->Auth = $ this ->getMockBuilder ('Cake\Controller\Component\AuthComponent ' )
277- ->setMethods (['user ' , 'isAuthorized ' ])
278- ->disableOriginalConstructor ()
279- ->getMock ();
277+ ->setMethods (['user ' , 'isAuthorized ' ])
278+ ->disableOriginalConstructor ()
279+ ->getMock ();
280280 $ this ->Controller ->Auth ->expects ($ this ->never ())
281- ->method ('user ' );
281+ ->method ('user ' );
282282 $ result = $ this ->Controller ->UsersAuth ->isUrlAuthorized ($ event );
283283 }
284284
@@ -298,11 +298,11 @@ public function testIsUrlAuthorizedMissingRouteArray()
298298 ],
299299 ];
300300 $ this ->Controller ->Auth = $ this ->getMockBuilder ('Cake\Controller\Component\AuthComponent ' )
301- ->setMethods (['user ' , 'isAuthorized ' ])
302- ->disableOriginalConstructor ()
303- ->getMock ();
301+ ->setMethods (['user ' , 'isAuthorized ' ])
302+ ->disableOriginalConstructor ()
303+ ->getMock ();
304304 $ this ->Controller ->Auth ->expects ($ this ->never ())
305- ->method ('user ' );
305+ ->method ('user ' );
306306 $ result = $ this ->Controller ->UsersAuth ->isUrlAuthorized ($ event );
307307 }
308308
@@ -318,24 +318,24 @@ public function testIsUrlAuthorizedUrlAbsoluteForCurrentAppString()
318318 'url ' => Router::fullBaseUrl () . '/route ' ,
319319 ];
320320 $ this ->Controller ->Auth = $ this ->getMockBuilder ('Cake\Controller\Component\AuthComponent ' )
321- ->setMethods (['user ' , 'isAuthorized ' ])
322- ->disableOriginalConstructor ()
323- ->getMock ();
321+ ->setMethods (['user ' , 'isAuthorized ' ])
322+ ->disableOriginalConstructor ()
323+ ->getMock ();
324324 $ this ->Controller ->Auth ->expects ($ this ->once ())
325- ->method ('user ' )
326- ->will ($ this ->returnValue (['id ' => 1 ]));
327- $ request = new Request ('/route ' );
328- $ request ->params = [
329- 'plugin ' => 'CakeDC/Users ' ,
330- 'controller ' => 'Users ' ,
331- 'action ' => 'requestResetPassword ' ,
332- 'pass ' => [],
333- '_matchedRoute ' => '/route/* ' ,
334- ];
325+ ->method ('user ' )
326+ ->will ($ this ->returnValue (['id ' => 1 ]));
335327 $ this ->Controller ->Auth ->expects ($ this ->once ())
336- ->method ('isAuthorized ' )
337- ->with (null , $ request )
338- ->will ($ this ->returnValue (true ));
328+ ->method ('isAuthorized ' )
329+ ->with (null , $ this ->callback (function ($ subject ) {
330+ return $ subject ->params === [
331+ 'pass ' => [],
332+ 'plugin ' => 'CakeDC/Users ' ,
333+ 'controller ' => 'Users ' ,
334+ 'action ' => 'requestResetPassword ' ,
335+ '_matchedRoute ' => '/route/* ' ,
336+ ];
337+ }))
338+ ->will ($ this ->returnValue (true ));
339339 $ result = $ this ->Controller ->UsersAuth ->isUrlAuthorized ($ event );
340340 $ this ->assertTrue ($ result );
341341 }
@@ -352,24 +352,24 @@ public function testIsUrlAuthorizedUrlRelativeForCurrentAppString()
352352 'url ' => 'route ' ,
353353 ];
354354 $ this ->Controller ->Auth = $ this ->getMockBuilder ('Cake\Controller\Component\AuthComponent ' )
355- ->setMethods (['user ' , 'isAuthorized ' ])
356- ->disableOriginalConstructor ()
357- ->getMock ();
355+ ->setMethods (['user ' , 'isAuthorized ' ])
356+ ->disableOriginalConstructor ()
357+ ->getMock ();
358358 $ this ->Controller ->Auth ->expects ($ this ->once ())
359- ->method ('user ' )
360- ->will ($ this ->returnValue (['id ' => 1 ]));
361- $ request = new Request ('/route ' );
362- $ request ->params = [
363- 'plugin ' => 'CakeDC/Users ' ,
364- 'controller ' => 'Users ' ,
365- 'action ' => 'requestResetPassword ' ,
366- 'pass ' => [],
367- '_matchedRoute ' => '/route/* ' ,
368- ];
359+ ->method ('user ' )
360+ ->will ($ this ->returnValue (['id ' => 1 ]));
369361 $ this ->Controller ->Auth ->expects ($ this ->once ())
370- ->method ('isAuthorized ' )
371- ->with (null , $ request )
372- ->will ($ this ->returnValue (true ));
362+ ->method ('isAuthorized ' )
363+ ->with (null , $ this ->callback (function ($ subject ) {
364+ return $ subject ->params === [
365+ 'pass ' => [],
366+ 'plugin ' => 'CakeDC/Users ' ,
367+ 'controller ' => 'Users ' ,
368+ 'action ' => 'requestResetPassword ' ,
369+ '_matchedRoute ' => '/route/* ' ,
370+ ];
371+ }))
372+ ->will ($ this ->returnValue (true ));
373373 $ result = $ this ->Controller ->UsersAuth ->isUrlAuthorized ($ event );
374374 $ this ->assertTrue ($ result );
375375 }
@@ -386,11 +386,11 @@ public function testIsUrlAuthorizedUrlAbsoluteForOtherAppString()
386386 'url ' => 'http://example.com ' ,
387387 ];
388388 $ this ->Controller ->Auth = $ this ->getMockBuilder ('Cake\Controller\Component\AuthComponent ' )
389- ->setMethods (['user ' , 'isAuthorized ' ])
390- ->disableOriginalConstructor ()
391- ->getMock ();
389+ ->setMethods (['user ' , 'isAuthorized ' ])
390+ ->disableOriginalConstructor ()
391+ ->getMock ();
392392 $ this ->Controller ->Auth ->expects ($ this ->never ())
393- ->method ('user ' );
393+ ->method ('user ' );
394394 $ result = $ this ->Controller ->UsersAuth ->isUrlAuthorized ($ event );
395395 $ this ->assertTrue ($ result );
396396 }
@@ -412,24 +412,24 @@ public function testIsUrlAuthorizedUrlArray()
412412 ],
413413 ];
414414 $ this ->Controller ->Auth = $ this ->getMockBuilder ('Cake\Controller\Component\AuthComponent ' )
415- ->setMethods (['user ' , 'isAuthorized ' ])
416- ->disableOriginalConstructor ()
417- ->getMock ();
415+ ->setMethods (['user ' , 'isAuthorized ' ])
416+ ->disableOriginalConstructor ()
417+ ->getMock ();
418418 $ this ->Controller ->Auth ->expects ($ this ->once ())
419- ->method ('user ' )
420- ->will ($ this ->returnValue (['id ' => 1 ]));
421- $ request = new Request ('/route/pass-one ' );
422- $ request ->params = [
423- 'plugin ' => 'CakeDC/Users ' ,
424- 'controller ' => 'Users ' ,
425- 'action ' => 'requestResetPassword ' ,
426- 'pass ' => ['pass-one ' ],
427- '_matchedRoute ' => '/route/* ' ,
428- ];
419+ ->method ('user ' )
420+ ->will ($ this ->returnValue (['id ' => 1 ]));
429421 $ this ->Controller ->Auth ->expects ($ this ->once ())
430- ->method ('isAuthorized ' )
431- ->with (null , $ request )
432- ->will ($ this ->returnValue (true ));
422+ ->method ('isAuthorized ' )
423+ ->with (null , $ this ->callback (function ($ subject ) {
424+ return $ subject ->params === [
425+ 'pass ' => ['pass-one ' ],
426+ 'plugin ' => 'CakeDC/Users ' ,
427+ 'controller ' => 'Users ' ,
428+ 'action ' => 'requestResetPassword ' ,
429+ '_matchedRoute ' => '/route/* ' ,
430+ ];
431+ }))
432+ ->will ($ this ->returnValue (true ));
433433 $ result = $ this ->Controller ->UsersAuth ->isUrlAuthorized ($ event );
434434 $ this ->assertTrue ($ result );
435435 }
0 commit comments