Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: check that UserStatusAutomation is cleaned up
Signed-off-by: Salvatore Martire <[email protected]>
  • Loading branch information
salmart-dev committed Jul 1, 2025
commit 289b7ab6845576c6cb7a96df1631d549cfb5ddab
27 changes: 27 additions & 0 deletions apps/dav/tests/unit/DAV/Listener/UserEventsListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

namespace OCA\DAV\Tests\unit\DAV\Listener;

use OCA\DAV\BackgroundJob\UserStatusAutomation;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CardDAV\CardDavBackend;
use OCA\DAV\CardDAV\SyncService;
use OCA\DAV\Listener\UserEventsListener;
use OCA\DAV\Service\ExampleContactService;
use OCA\DAV\Service\ExampleEventService;
use OCP\BackgroundJob\IJobList;
use OCP\Defaults;
use OCP\IUser;
use OCP\IUserManager;
Expand Down Expand Up @@ -46,6 +48,7 @@ protected function setUp(): void {
$this->exampleContactService = $this->createMock(ExampleContactService::class);
$this->exampleEventService = $this->createMock(ExampleEventService::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->jobList = $this->createMock(IJobList::class);

$this->userEventsListener = new UserEventsListener(
$this->userManager,
Expand All @@ -56,6 +59,7 @@ protected function setUp(): void {
$this->exampleContactService,
$this->exampleEventService,
$this->logger,
$this->jobList,
);
}

Expand Down Expand Up @@ -153,4 +157,27 @@ public function testDeleteCalendar(): void {
$this->userEventsListener->preDeleteUser($user);
$this->userEventsListener->postDeleteUser('newUser');
}

public function testDeleteUserAutomationEvent(): void {
$user = $this->createMock(IUser::class);
$user->expects($this->once())->method('getUID')->willReturn('newUser');

$this->syncService->expects($this->once())
->method('deleteUser');

$this->calDavBackend->expects($this->once())->method('getUsersOwnCalendars')->willReturn([
['id' => []]
]);
$this->calDavBackend->expects($this->once())->method('getSubscriptionsForUser')->willReturn([
['id' => []]
]);
$this->cardDavBackend->expects($this->once())->method('getUsersOwnAddressBooks')->willReturn([
['id' => []]
]);

$this->jobList->expects(self::once())->method('remove')->with(UserStatusAutomation::class, ['userId' => 'newUser']);

$this->userEventsListener->preDeleteUser($user);
$this->userEventsListener->postDeleteUser('newUser');
}
}
Loading