Skip to content

Commit d54879e

Browse files
committed
Edited login test to expect UserLoggedInEvent
Signed-off-by: Malik <3097625+dermalikmann@users.noreply.github.com>
1 parent ffddf52 commit d54879e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

tests/unit/Controller/SAMLControllerTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use OCA\User_SAML\UserResolver;
3232
use OCP\AppFramework\Http\RedirectResponse;
3333
use OCP\AppFramework\Http\TemplateResponse;
34+
use OCP\EventDispatcher\IEventDispatcher;
3435
use OCP\IConfig;
3536
use OCP\IL10N;
3637
use OCP\IRequest;
@@ -72,6 +73,7 @@ class SAMLControllerTest extends TestCase {
7273
/** @var SAMLController */
7374
private $samlController;
7475
private ITrustedDomainHelper|MockObject $trustedDomainController;
76+
private IEventDispatcher $eventDispatcher;
7577

7678
protected function setUp(): void {
7779
parent::setUp();
@@ -89,6 +91,7 @@ protected function setUp(): void {
8991
$this->userData = $this->createMock(UserData::class);
9092
$this->crypto = $this->createMock(ICrypto::class);
9193
$this->trustedDomainController = $this->createMock(ITrustedDomainHelper::class);
94+
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
9295

9396
$this->l->expects($this->any())->method('t')->willReturnCallback(
9497
function ($param) {
@@ -336,6 +339,11 @@ public function testLoginWithEnvVariable(array $samlUserData, string $redirect,
336339
->method('createUserIfNotExists')
337340
->with('MyUid');
338341

342+
$this->eventDispatcher
343+
->expects($this->once())
344+
->method('dispatchTyped')
345+
->with(new UserLoggedInEvent($user, 'MyUid', null, false));
346+
339347
$expected = new RedirectResponse($redirect);
340348
$result = $this->samlController->login(1);
341349
$this->assertEquals($expected, $result);

0 commit comments

Comments
 (0)