@@ -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
/**
@@ -749,10 +753,13 @@ public function testGetImpersonationAuthenticationServiceFailure()
749
753
{
750
754
$ service = $ this ->getMockBuilder (AuthenticationServiceInterface::class)->getMock ();
751
755
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 );
756
763
757
764
$ this ->expectException (InvalidArgumentException::class);
758
765
$ classname = get_class ($ service );
0 commit comments