File tree 2 files changed +9
-1
lines changed
tests/TestCase/Controller/Component
2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -445,6 +445,10 @@ public function stopImpersonating()
445
445
*/
446
446
public function isImpersonating (): bool
447
447
{
448
+ if (!$ this ->getIdentity ()) {
449
+ return false ;
450
+ }
451
+
448
452
$ service = $ this ->getImpersonationAuthenticationService ();
449
453
$ controller = $ this ->getController ();
450
454
Original file line number Diff line number Diff line change @@ -731,13 +731,17 @@ public function testIsImpersonating()
731
731
$ this ->request ->getSession ()->write ('AuthImpersonate ' , $ impersonator );
732
732
$ this ->service ->authenticate ($ this ->request );
733
733
$ request = $ this ->request
734
- ->withAttribute ('authentication ' , $ this ->service );
734
+ ->withAttribute ('authentication ' , $ this ->service )
735
+ ->withAttribute ('identity ' , new Identity ($ impersonated ));
735
736
$ controller = new Controller ($ request , $ this ->response );
736
737
$ registry = new ComponentRegistry ($ controller );
737
738
$ component = new AuthenticationComponent ($ registry );
738
739
739
740
$ result = $ component ->isImpersonating ();
740
741
$ this ->assertTrue ($ result );
742
+
743
+ $ component ->logout ();
744
+ $ this ->assertFalse ($ component ->isImpersonating ());
741
745
}
742
746
743
747
/**
You can’t perform that action at this time.
0 commit comments