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
Next Next commit
Fix unit tests
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen authored and skjnldsv committed May 31, 2022
commit ee0e9b7d3a01ce7042b0e34858d45e1bf41fe9f8
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OCA\UserStatus\Db\UserStatusMapper;
use OCA\UserStatus\Listener\UserDeletedListener;
use OCA\UserStatus\Listener\UserLiveStatusListener;
use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\GenericEvent;
Expand All @@ -41,7 +42,8 @@ class UserLiveStatusListenerTest extends TestCase {

/** @var UserStatusMapper|\PHPUnit\Framework\MockObject\MockObject */
private $mapper;

/** @var StatusService|\PHPUnit\Framework\MockObject\MockObject */
private $statusService;
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
private $timeFactory;

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

$this->mapper = $this->createMock(UserStatusMapper::class);
$this->statusService = $this->createMock(StatusService::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->listener = new UserLiveStatusListener($this->mapper, $this->timeFactory);
$this->listener = new UserLiveStatusListener($this->mapper, $this->statusService, $this->timeFactory);
}

/**
Expand Down Expand Up @@ -85,12 +88,12 @@ public function testHandleWithCorrectEvent(string $userId,
$userStatus->setStatusTimestamp($previousTimestamp);
$userStatus->setIsUserDefined($previousIsUserDefined);

$this->mapper->expects($this->once())
$this->statusService->expects($this->once())
->method('findByUserId')
->with($userId)
->willReturn($userStatus);
} else {
$this->mapper->expects($this->once())
$this->statusService->expects($this->once())
->method('findByUserId')
->with($userId)
->willThrowException(new DoesNotExistException(''));
Expand Down