1616use OCA \User_SAML \UserResolver ;
1717use OCP \AppFramework \Http \RedirectResponse ;
1818use OCP \AppFramework \Http \TemplateResponse ;
19+ use OCP \EventDispatcher \IEventDispatcher ;
1920use OCP \IConfig ;
2021use OCP \IL10N ;
2122use OCP \IRequest ;
@@ -57,6 +58,7 @@ class SAMLControllerTest extends TestCase {
5758 /** @var SAMLController */
5859 private $ samlController ;
5960 private ITrustedDomainHelper |MockObject $ trustedDomainController ;
61+ private IEventDispatcher $ eventDispatcher ;
6062
6163 protected function setUp (): void {
6264 parent ::setUp ();
@@ -74,6 +76,7 @@ protected function setUp(): void {
7476 $ this ->userData = $ this ->createMock (UserData::class);
7577 $ this ->crypto = $ this ->createMock (ICrypto::class);
7678 $ this ->trustedDomainController = $ this ->createMock (ITrustedDomainHelper::class);
79+ $ this ->eventDispatcher = $ this ->createMock (IEventDispatcher::class);
7780
7881 $ this ->l ->expects ($ this ->any ())->method ('t ' )->willReturnCallback (
7982 function ($ param ) {
@@ -321,6 +324,11 @@ public function testLoginWithEnvVariable(array $samlUserData, string $redirect,
321324 ->method ('createUserIfNotExists ' )
322325 ->with ('MyUid ' );
323326
327+ $ this ->eventDispatcher
328+ ->expects ($ this ->once ())
329+ ->method ('dispatchTyped ' )
330+ ->with (new UserLoggedInEvent ($ user , 'MyUid ' , null , false ));
331+
324332 $ expected = new RedirectResponse ($ redirect );
325333 $ result = $ this ->samlController ->login (1 );
326334 $ this ->assertEquals ($ expected , $ result );
0 commit comments