logger = $this->createMock(AuditLogger::class); $this->security = new SecurityEventListener($this->logger); $this->user = $this->createMock(IUser::class); $this->user->method('getUID')->willReturn('myuid'); $this->user->method('getDisplayName')->willReturn('mydisplayname'); $this->provider = $this->createMock(IProvider::class); $this->provider->method('getDisplayName')->willReturn('myprovider'); } public function testTwofactorFailed(): void { $this->logger->expects($this->once()) ->method('info') ->with( $this->equalTo('Failed two factor attempt by user mydisplayname (myuid) with provider myprovider'), ['app' => 'admin_audit'] ); $this->security->handle(new twoFactorProviderChallengeFailed($this->user, $this->provider)); } public function testTwofactorSuccess(): void { $this->logger->expects($this->once()) ->method('info') ->with( $this->equalTo('Successful two factor attempt by user mydisplayname (myuid) with provider myprovider'), ['app' => 'admin_audit'] ); $this->security->handle(new TwoFactorProviderChallengePassed($this->user, $this->provider)); } }