Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-06-04 13:03:16 +0300
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-06-07 13:14:35 +0300
commitd06f3cc51a5820fd1fa3642598d8880bd2623e2d (patch)
treec56c24745959250d307da110c35b489a5944ed81 /apps/user_status/tests/Unit
parent4136993f4403c80f61aa8802a8ce3d7e892d890a (diff)
Don't update statuses to offline again and again
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/user_status/tests/Unit')
-rw-r--r--apps/user_status/tests/Unit/Db/UserStatusMapperTest.php1
-rw-r--r--apps/user_status/tests/Unit/Service/StatusServiceTest.php41
2 files changed, 42 insertions, 0 deletions
diff --git a/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php b/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php
index e86cee6d68a..74430219cb9 100644
--- a/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php
+++ b/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php
@@ -187,6 +187,7 @@ class UserStatusMapperTest extends TestCase {
public function clearStatusesOlderThanDataProvider(): array {
return [
+ ['offline', false, 6000, false],
['online', true, 6000, false],
['online', true, 4000, true],
['online', false, 6000, false],
diff --git a/apps/user_status/tests/Unit/Service/StatusServiceTest.php b/apps/user_status/tests/Unit/Service/StatusServiceTest.php
index 1e61f5b09ca..77209b70f48 100644
--- a/apps/user_status/tests/Unit/Service/StatusServiceTest.php
+++ b/apps/user_status/tests/Unit/Service/StatusServiceTest.php
@@ -37,6 +37,7 @@ use OCA\UserStatus\Service\PredefinedStatusService;
use OCA\UserStatus\Service\StatusService;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\UserStatus\IUserStatus;
use Test\TestCase;
class StatusServiceTest extends TestCase {
@@ -623,4 +624,44 @@ class StatusServiceTest extends TestCase {
$actual = $this->service->removeUserStatus('john.doe');
$this->assertFalse($actual);
}
+
+ public function testCleanStatusAutomaticOnline(): void {
+ $status = new UserStatus();
+ $status->setStatus(IUserStatus::ONLINE);
+ $status->setStatusTimestamp(1337);
+ $status->setIsUserDefined(false);
+
+ $this->mapper->expects(self::once())
+ ->method('update')
+ ->with($status);
+
+ parent::invokePrivate($this->service, 'cleanStatus', [$status]);
+ }
+
+ public function testCleanStatusCustomOffline(): void {
+ $status = new UserStatus();
+ $status->setStatus(IUserStatus::OFFLINE);
+ $status->setStatusTimestamp(1337);
+ $status->setIsUserDefined(true);
+
+ $this->mapper->expects(self::once())
+ ->method('update')
+ ->with($status);
+
+ parent::invokePrivate($this->service, 'cleanStatus', [$status]);
+ }
+
+ public function testCleanStatusCleanedAlready(): void {
+ $status = new UserStatus();
+ $status->setStatus(IUserStatus::OFFLINE);
+ $status->setStatusTimestamp(1337);
+ $status->setIsUserDefined(false);
+
+ // Don't update the status again and again when no value changed
+ $this->mapper->expects(self::never())
+ ->method('update')
+ ->with($status);
+
+ parent::invokePrivate($this->service, 'cleanStatus', [$status]);
+ }
}