3030use OCA \UserStatus \Db \UserStatusMapper ;
3131use OCA \UserStatus \Listener \UserDeletedListener ;
3232use OCA \UserStatus \Listener \UserLiveStatusListener ;
33+ use OCA \UserStatus \Service \StatusService ;
3334use OCP \AppFramework \Db \DoesNotExistException ;
3435use OCP \AppFramework \Utility \ITimeFactory ;
3536use 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