Skip to content

Commit d61bcd3

Browse files
dermalikmannblizzz
authored andcommitted
Edited login test to expect UserLoggedInEvent
Signed-off-by: Malik <3097625+dermalikmann@users.noreply.github.com>
1 parent 88cfe38 commit d61bcd3

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
@@ -16,6 +16,7 @@
1616
use OCA\User_SAML\UserResolver;
1717
use OCP\AppFramework\Http\RedirectResponse;
1818
use OCP\AppFramework\Http\TemplateResponse;
19+
use OCP\EventDispatcher\IEventDispatcher;
1920
use OCP\IConfig;
2021
use OCP\IL10N;
2122
use 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

Comments
 (0)