Skip to content

Commit 3b4f077

Browse files
committed
Fix unit tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent d3601ed commit 3b4f077

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

apps/user_status/tests/Unit/Listener/UserLiveStatusListenerTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use OCA\UserStatus\Db\UserStatusMapper;
3131
use OCA\UserStatus\Listener\UserDeletedListener;
3232
use OCA\UserStatus\Listener\UserLiveStatusListener;
33+
use OCA\UserStatus\Service\StatusService;
3334
use OCP\AppFramework\Db\DoesNotExistException;
3435
use OCP\AppFramework\Utility\ITimeFactory;
3536
use OCP\EventDispatcher\GenericEvent;
@@ -41,7 +42,8 @@ class UserLiveStatusListenerTest extends TestCase {
4142

4243
/** @var UserStatusMapper|\PHPUnit\Framework\MockObject\MockObject */
4344
private $mapper;
44-
45+
/** @var StatusService|\PHPUnit\Framework\MockObject\MockObject */
46+
private $statusService;
4547
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
4648
private $timeFactory;
4749

@@ -52,8 +54,9 @@ protected function setUp(): void {
5254
parent::setUp();
5355

5456
$this->mapper = $this->createMock(UserStatusMapper::class);
57+
$this->statusService = $this->createMock(StatusService::class);
5558
$this->timeFactory = $this->createMock(ITimeFactory::class);
56-
$this->listener = new UserLiveStatusListener($this->mapper, $this->timeFactory);
59+
$this->listener = new UserLiveStatusListener($this->mapper, $this->statusService, $this->timeFactory);
5760
}
5861

5962
/**
@@ -85,12 +88,12 @@ public function testHandleWithCorrectEvent(string $userId,
8588
$userStatus->setStatusTimestamp($previousTimestamp);
8689
$userStatus->setIsUserDefined($previousIsUserDefined);
8790

88-
$this->mapper->expects($this->once())
91+
$this->statusService->expects($this->once())
8992
->method('findByUserId')
9093
->with($userId)
9194
->willReturn($userStatus);
9295
} else {
93-
$this->mapper->expects($this->once())
96+
$this->statusService->expects($this->once())
9497
->method('findByUserId')
9598
->with($userId)
9699
->willThrowException(new DoesNotExistException(''));

0 commit comments

Comments
 (0)