@@ -334,13 +334,14 @@ public function testLogoutRemovesSessionTokenAndRememberMeCookie()
334
334
$ user ->shouldReceive ('getRememberToken ' )->once ()->andReturn ('a ' );
335
335
$ user ->shouldReceive ('setRememberToken ' )->once ();
336
336
$ mock ->expects ($ this ->once ())->method ('getName ' )->willReturn ('foo ' );
337
- $ mock ->expects ($ this ->once ( ))->method ('getRecallerName ' )->willReturn ('bar ' );
337
+ $ mock ->expects ($ this ->exactly ( 2 ))->method ('getRecallerName ' )->willReturn ($ recallerName = 'bar ' );
338
338
$ mock ->expects ($ this ->once ())->method ('recaller ' )->willReturn ('non-null-cookie ' );
339
339
$ provider ->shouldReceive ('updateRememberToken ' )->once ();
340
340
341
341
$ cookie = m::mock (Cookie::class);
342
342
$ cookies ->shouldReceive ('forget ' )->once ()->with ('bar ' )->andReturn ($ cookie );
343
343
$ cookies ->shouldReceive ('queue ' )->once ()->with ($ cookie );
344
+ $ cookies ->shouldReceive ('unqueue ' )->once ()->with ($ recallerName );
344
345
$ mock ->getSession ()->shouldReceive ('remove ' )->once ()->with ('foo ' );
345
346
$ mock ->setUser ($ user );
346
347
$ mock ->logout ();
@@ -350,13 +351,16 @@ public function testLogoutRemovesSessionTokenAndRememberMeCookie()
350
351
public function testLogoutDoesNotEnqueueRememberMeCookieForDeletionIfCookieDoesntExist ()
351
352
{
352
353
[$ session , $ provider , $ request , $ cookie ] = $ this ->getMocks ();
353
- $ mock = $ this ->getMockBuilder (SessionGuard::class)->onlyMethods (['getName ' , 'recaller ' ])->setConstructorArgs (['default ' , $ provider , $ session , $ request ])->getMock ();
354
+ $ mock = $ this ->getMockBuilder (SessionGuard::class)->onlyMethods (['getName ' , 'getRecallerName ' , ' recaller ' ])->setConstructorArgs (['default ' , $ provider , $ session , $ request ])->getMock ();
354
355
$ mock ->setCookieJar ($ cookies = m::mock (CookieJar::class));
355
356
$ user = m::mock (Authenticatable::class);
356
357
$ user ->shouldReceive ('getRememberToken ' )->andReturn (null );
358
+ $ mock ->expects ($ this ->once ())->method ('getRecallerName ' )->willReturn ($ recallerName = 'bar ' );
357
359
$ mock ->expects ($ this ->once ())->method ('getName ' )->willReturn ('foo ' );
358
360
$ mock ->expects ($ this ->once ())->method ('recaller ' )->willReturn (null );
359
361
362
+ $ cookies ->shouldReceive ('unqueue ' )->with ($ recallerName );
363
+
360
364
$ mock ->getSession ()->shouldReceive ('remove ' )->once ()->with ('foo ' );
361
365
$ mock ->setUser ($ user );
362
366
$ mock ->logout ();
@@ -398,12 +402,13 @@ public function testLogoutCurrentDeviceRemovesRememberMeCookie()
398
402
$ mock ->setCookieJar ($ cookies = m::mock (CookieJar::class));
399
403
$ user = m::mock (Authenticatable::class);
400
404
$ mock ->expects ($ this ->once ())->method ('getName ' )->willReturn ('foo ' );
401
- $ mock ->expects ($ this ->once ( ))->method ('getRecallerName ' )->willReturn ('bar ' );
405
+ $ mock ->expects ($ this ->exactly ( 2 ))->method ('getRecallerName ' )->willReturn ($ recallerName = 'bar ' );
402
406
$ mock ->expects ($ this ->once ())->method ('recaller ' )->willReturn ('non-null-cookie ' );
403
407
404
408
$ cookie = m::mock (Cookie::class);
405
409
$ cookies ->shouldReceive ('forget ' )->once ()->with ('bar ' )->andReturn ($ cookie );
406
410
$ cookies ->shouldReceive ('queue ' )->once ()->with ($ cookie );
411
+ $ cookies ->shouldReceive ('unqueue ' )->once ()->with ($ recallerName );
407
412
$ mock ->getSession ()->shouldReceive ('remove ' )->once ()->with ('foo ' );
408
413
$ mock ->setUser ($ user );
409
414
$ mock ->logoutCurrentDevice ();
@@ -413,12 +418,14 @@ public function testLogoutCurrentDeviceRemovesRememberMeCookie()
413
418
public function testLogoutCurrentDeviceDoesNotEnqueueRememberMeCookieForDeletionIfCookieDoesntExist ()
414
419
{
415
420
[$ session , $ provider , $ request , $ cookie ] = $ this ->getMocks ();
416
- $ mock = $ this ->getMockBuilder (SessionGuard::class)->onlyMethods (['getName ' , 'recaller ' ])->setConstructorArgs (['default ' , $ provider , $ session , $ request ])->getMock ();
421
+ $ mock = $ this ->getMockBuilder (SessionGuard::class)->onlyMethods (['getName ' , 'getRecallerName ' , ' recaller ' ])->setConstructorArgs (['default ' , $ provider , $ session , $ request ])->getMock ();
417
422
$ mock ->setCookieJar ($ cookies = m::mock (CookieJar::class));
418
423
$ user = m::mock (Authenticatable::class);
419
424
$ user ->shouldReceive ('getRememberToken ' )->andReturn (null );
420
425
$ mock ->expects ($ this ->once ())->method ('getName ' )->willReturn ('foo ' );
426
+ $ mock ->expects ($ this ->once ())->method ('getRecallerName ' )->willReturn ($ recallerName = 'bar ' );
421
427
$ mock ->expects ($ this ->once ())->method ('recaller ' )->willReturn (null );
428
+ $ cookies ->shouldReceive ('unqueue ' )->once ()->with ($ recallerName );
422
429
423
430
$ mock ->getSession ()->shouldReceive ('remove ' )->once ()->with ('foo ' );
424
431
$ mock ->setUser ($ user );
0 commit comments