1919use OCP \AppFramework \Http \RedirectResponse ;
2020use OCP \AppFramework \Http \TemplateResponse ;
2121use OCP \AppFramework \Services \IAppConfig ;
22+ use OCP \EventDispatcher \IEventDispatcher ;
2223use OCP \IConfig ;
2324use OCP \IL10N ;
2425use OCP \IRequest ;
2829use OCP \IUserSession ;
2930use OCP \Security \ICrypto ;
3031use OCP \Security \ITrustedDomainHelper ;
32+ use OCP \User \Events \UserLoggedInEvent ;
3133use Override ;
3234use PHPUnit \Framework \Attributes \DataProvider ;
3335use PHPUnit \Framework \MockObject \MockObject ;
@@ -49,8 +51,9 @@ class SAMLControllerTest extends TestCase {
4951 private IL10N &MockObject $ l ;
5052 private ICrypto &MockObject $ crypto ;
5153 private SAMLController $ samlController ;
52- private ITrustedDomainHelper |MockObject $ trustedDomainController ;
53- private SessionService |MockObject $ sessionService ;
54+ private ITrustedDomainHelper &MockObject $ trustedDomainController ;
55+ private SessionService &MockObject $ sessionService ;
56+ private IEventDispatcher &MockObject $ eventDispatcher ;
5457
5558 #[Override]
5659 protected function setUp (): void {
@@ -71,6 +74,7 @@ protected function setUp(): void {
7174 $ this ->crypto = $ this ->createMock (ICrypto::class);
7275 $ this ->trustedDomainController = $ this ->createMock (ITrustedDomainHelper::class);
7376 $ this ->sessionService = $ this ->createMock (SessionService::class);
77+ $ this ->eventDispatcher = $ this ->createMock (IEventDispatcher::class);
7478
7579 $ this ->l ->expects ($ this ->any ())->method ('t ' )->willReturnCallback (
7680 static fn (string $ param ): string => $ param
@@ -95,7 +99,8 @@ protected function setUp(): void {
9599 $ this ->userData ,
96100 $ this ->crypto ,
97101 $ this ->trustedDomainController ,
98- $ this ->sessionService
102+ $ this ->sessionService ,
103+ $ this ->eventDispatcher ,
99104 );
100105 }
101106
@@ -263,6 +268,7 @@ public function testLoginWithEnvVariable(array $samlUserData, string $redirect,
263268
264269 if (isset ($ samlUserData ['uid ' ]) && !($ userState === 0 && $ autoProvision === 0 )) {
265270 $ user = $ this ->createMock (IUser::class);
271+ $ user ->method ('getUID ' )->willReturn ('MyUid ' );
266272 $ im = $ this ->userResolver
267273 ->expects ($ this ->once ())
268274 ->method ('findExistingUser ' )
0 commit comments