@@ -731,13 +731,17 @@ public function testIsImpersonating()
731731 $ this ->request ->getSession ()->write ('AuthImpersonate ' , $ impersonator );
732732 $ this ->service ->authenticate ($ this ->request );
733733 $ request = $ this ->request
734- ->withAttribute ('authentication ' , $ this ->service );
734+ ->withAttribute ('authentication ' , $ this ->service )
735+ ->withAttribute ('identity ' , new Identity ($ impersonated ));
735736 $ controller = new Controller ($ request , $ this ->response );
736737 $ registry = new ComponentRegistry ($ controller );
737738 $ component = new AuthenticationComponent ($ registry );
738739
739740 $ result = $ component ->isImpersonating ();
740741 $ this ->assertTrue ($ result );
742+
743+ $ component ->logout ();
744+ $ this ->assertFalse ($ component ->isImpersonating ());
741745 }
742746
743747 /**
@@ -749,10 +753,13 @@ public function testGetImpersonationAuthenticationServiceFailure()
749753 {
750754 $ service = $ this ->getMockBuilder (AuthenticationServiceInterface::class)->getMock ();
751755
752- $ component = $ this ->createPartialMock (AuthenticationComponent::class, ['getAuthenticationService ' ]);
753- $ component ->expects ($ this ->once ())
754- ->method ('getAuthenticationService ' )
755- ->willReturn ($ service );
756+ $ user = new ArrayObject (['username ' => 'mariano ' ]);
757+ $ request = $ this ->request
758+ ->withAttribute ('authentication ' , $ service )
759+ ->withAttribute ('identity ' , new Identity ($ user ));
760+ $ controller = new Controller ($ request , $ this ->response );
761+ $ registry = new ComponentRegistry ($ controller );
762+ $ component = new AuthenticationComponent ($ registry );
756763
757764 $ this ->expectException (InvalidArgumentException::class);
758765 $ classname = get_class ($ service );
0 commit comments