diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2021-06-07 12:12:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-07 12:12:33 +0200 |
commit | 56b68ce4e07835ecb806bc996e5648e433c5650b (patch) | |
tree | 4df62595b80d2ece7900f4f29fc8cf60f48637ef /apps/user_status/tests | |
parent | 92d19bd79bb9c8c541acabdd29c7cba065a54579 (diff) | |
parent | 55c44580c26aed3185f10eec5e943b8e82166d04 (diff) | |
download | nextcloud-server-56b68ce4e07835ecb806bc996e5648e433c5650b.tar.gz nextcloud-server-56b68ce4e07835ecb806bc996e5648e433c5650b.zip |
Merge pull request #27375 from nextcloud/bugfix/noid/dont-update-offline-status
Don't update statuses to offline again and again
Diffstat (limited to 'apps/user_status/tests')
-rw-r--r-- | apps/user_status/tests/Unit/Db/UserStatusMapperTest.php | 1 | ||||
-rw-r--r-- | apps/user_status/tests/Unit/Service/StatusServiceTest.php | 41 |
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 3959d1f91ef..ddb067b862b 100644 --- a/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php +++ b/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php @@ -188,6 +188,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 44f885a207a..b4215778a99 100644 --- a/apps/user_status/tests/Unit/Service/StatusServiceTest.php +++ b/apps/user_status/tests/Unit/Service/StatusServiceTest.php @@ -38,6 +38,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 { @@ -624,4 +625,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]); + } } |