@@ -58,7 +58,7 @@ public function setUp(): void
5858 parent ::setUp ();
5959 $ request = new ServerRequest ();
6060 $ this ->Trait = $ this ->getMockBuilder ('CakeDC\Users\Controller\UsersController ' )
61- ->onlyMethods (['dispatchEvent ' , 'redirect ' , 'set ' ])
61+ ->onlyMethods (['dispatchEvent ' , 'redirect ' , 'set ' , ' getUsersTable ' ])
6262 ->setConstructorArgs ([new ServerRequest ()])
6363 ->getMock ();
6464
@@ -142,11 +142,11 @@ public function testLinkSocialHappy()
142142
143143 $ this ->Provider ->expects ($ this ->any ())
144144 ->method ('getState ' )
145- ->will ( $ this -> returnValue ( '_NEW_STATE_ ' ) );
145+ ->willReturn ( '_NEW_STATE_ ' );
146146
147147 $ this ->Provider ->expects ($ this ->any ())
148148 ->method ('getAuthorizationUrl ' )
149- ->will ( $ this -> returnValue ( 'http://facebook.com/redirect/url ' ) );
149+ ->willReturn ( 'http://facebook.com/redirect/url ' );
150150
151151 $ this ->Trait ->Flash ->expects ($ this ->never ())
152152 ->method ('error ' );
@@ -157,7 +157,7 @@ public function testLinkSocialHappy()
157157 $ this ->Trait ->expects ($ this ->once ())
158158 ->method ('redirect ' )
159159 ->with ($ this ->equalTo ('http://facebook.com/redirect/url ' ))
160- ->will ( $ this -> returnValue ( new Response () ));
160+ ->willReturn ( new Response ());
161161
162162 $ this ->Trait ->linkSocial ('facebook ' );
163163 }
@@ -226,14 +226,14 @@ public function testCallbackLinkSocialHappy()
226226 $ this ->equalTo ('authorization_code ' ),
227227 $ this ->equalTo (['code ' => 'ZPO9972j3092304230 ' ]),
228228 )
229- ->will ( $ this -> returnValue ( $ Token) );
229+ ->willReturn ( $ Token );
230230
231231 $ this ->Provider ->expects ($ this ->any ())
232232 ->method ('getResourceOwner ' )
233233 ->with (
234234 $ this ->equalTo ($ Token ),
235235 )
236- ->will ( $ this -> returnValue ( $ user) );
236+ ->willReturn ( $ user );
237237
238238 $ this ->Trait = $ this ->getMockBuilder ('CakeDC\Users\Controller\UsersController ' )
239239 ->onlyMethods (['dispatchEvent ' , 'redirect ' , 'set ' , 'getUsersTable ' , 'log ' ])
@@ -258,7 +258,7 @@ public function testCallbackLinkSocialHappy()
258258
259259 $ this ->Trait ->expects ($ this ->any ())
260260 ->method ('getUsersTable ' )
261- ->will ( $ this -> returnValue ( $ Table) );
261+ ->willReturn ( $ Table );
262262
263263 $ this ->_mockAuthLoggedIn ();
264264 $ this ->_mockDispatchEvent (new Event ('event ' ));
@@ -311,19 +311,26 @@ public function testCallbackLinkSocialWithValidationErrors()
311311 ]);
312312 $ Table = $ this ->getMockBuilder (\CakeDC \Users \Model \Table \UsersTable::class)
313313 ->setConstructorArgs ([['alias ' => 'Users ' , 'connection ' => \Cake \Datasource \ConnectionManager::get ('test ' )]])
314- ->onlyMethods (['newEntity ' , 'get ' ])
315- ->addMethods (['linkSocialAccount ' ])
314+ ->onlyMethods (['newEntity ' , 'get ' , 'getBehavior ' ])
315+ ->getMock ();
316+ $ behavior = $ this ->getMockBuilder (\CakeDC \Users \Model \Behavior \LinkSocialBehavior::class)
317+ ->disableOriginalConstructor ()
318+ ->onlyMethods (['linkSocialAccount ' ])
316319 ->getMock ();
317320
318321 $ Table ->setAlias ('Users ' );
319322
320323 $ Table ->expects ($ this ->once ())
321324 ->method ('get ' )
322- ->will ( $ this -> returnValue ( $ user) );
325+ ->willReturn ( $ user );
323326
324327 $ Table ->expects ($ this ->once ())
328+ ->method ('getBehavior ' )
329+ ->with ('LinkSocial ' )
330+ ->willReturn ($ behavior );
331+ $ behavior ->expects ($ this ->once ())
325332 ->method ('linkSocialAccount ' )
326- ->will ( $ this -> returnValue ( $ user) );
333+ ->willReturn ( $ user );
327334
328335 $ Token = new \League \OAuth2 \Client \Token \AccessToken ([
329336 'access_token ' => 'test-token ' ,
@@ -377,14 +384,14 @@ public function testCallbackLinkSocialWithValidationErrors()
377384 $ this ->equalTo ('authorization_code ' ),
378385 $ this ->equalTo (['code ' => 'ZPO9972j3092304230 ' ]),
379386 )
380- ->will ( $ this -> returnValue ( $ Token) );
387+ ->willReturn ( $ Token );
381388
382389 $ this ->Provider ->expects ($ this ->any ())
383390 ->method ('getResourceOwner ' )
384391 ->with (
385392 $ this ->equalTo ($ Token ),
386393 )
387- ->will ( $ this -> returnValue ( $ user) );
394+ ->willReturn ( $ user );
388395
389396 $ this ->Trait = $ this ->getMockBuilder ('CakeDC\Users\Controller\UsersController ' )
390397 ->onlyMethods (['dispatchEvent ' , 'redirect ' , 'set ' , 'getUsersTable ' , 'log ' ])
@@ -393,7 +400,7 @@ public function testCallbackLinkSocialWithValidationErrors()
393400
394401 $ this ->Trait ->expects ($ this ->any ())
395402 ->method ('getUsersTable ' )
396- ->will ( $ this -> returnValue ( $ Table) );
403+ ->willReturn ( $ Table );
397404
398405 $ this ->Trait ->setRequest (ServerRequestFactory::fromGlobals ());
399406 $ this ->Trait ->getRequest ()->getSession ()->write ('oauth2state ' , '__TEST_STATE__ ' );
0 commit comments