diff options
author | Joas Schilling <coding@schilljs.com> | 2022-02-15 15:28:55 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-02-15 16:06:33 +0100 |
commit | 058d1de26012ab829fad915f35b1bb761808ce7b (patch) | |
tree | e336ec7e9956fe07cb8db59642d5f86088068ef6 /apps/user_status/tests | |
parent | 5fcbb1ca62d7cfbffb0e4089f7315cdfe29668b0 (diff) | |
download | nextcloud-server-058d1de26012ab829fad915f35b1bb761808ce7b.tar.gz nextcloud-server-058d1de26012ab829fad915f35b1bb761808ce7b.zip |
Do status and predefined message setting in one go
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/user_status/tests')
-rw-r--r-- | apps/user_status/tests/Unit/Db/UserStatusMapperTest.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php b/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php index c48805b57af..0d9f1c1f718 100644 --- a/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php +++ b/apps/user_status/tests/Unit/Db/UserStatusMapperTest.php @@ -252,6 +252,67 @@ class UserStatusMapperTest extends TestCase { $this->mapper->insert($userStatus3); } + public function dataCreateBackupStatus(): array { + return [ + [false, false, false], + [true, false, true], + [false, true, false], + [true, true, false], + ]; + } + + /** + * @dataProvider dataCreateBackupStatus + * @param bool $hasStatus + * @param bool $hasBackup + * @param bool $backupCreated + */ + public function testCreateBackupStatus(bool $hasStatus, bool $hasBackup, bool $backupCreated): void { + if ($hasStatus) { + $userStatus1 = new UserStatus(); + $userStatus1->setUserId('user1'); + $userStatus1->setStatus('online'); + $userStatus1->setStatusTimestamp(5000); + $userStatus1->setIsUserDefined(true); + $userStatus1->setIsBackup(false); + $userStatus1->setCustomIcon('🚀'); + $userStatus1->setCustomMessage('Current'); + $userStatus1->setClearAt(50000); + $this->mapper->insert($userStatus1); + } + + if ($hasBackup) { + $userStatus1 = new UserStatus(); + $userStatus1->setUserId('_user1'); + $userStatus1->setStatus('online'); + $userStatus1->setStatusTimestamp(5000); + $userStatus1->setIsUserDefined(true); + $userStatus1->setIsBackup(true); + $userStatus1->setCustomIcon('🚀'); + $userStatus1->setCustomMessage('Backup'); + $userStatus1->setClearAt(50000); + $this->mapper->insert($userStatus1); + } + + if ($hasStatus && $hasBackup) { + $this->expectException(Exception::class); + } + + self::assertSame($backupCreated, $this->mapper->createBackupStatus('user1')); + + if ($backupCreated) { + $user1Status = $this->mapper->findByUserId('user1', true); + $this->assertEquals('_user1', $user1Status->getUserId()); + $this->assertEquals(true, $user1Status->getIsBackup()); + $this->assertEquals('Current', $user1Status->getCustomMessage()); + } else if ($hasBackup) { + $user1Status = $this->mapper->findByUserId('user1', true); + $this->assertEquals('_user1', $user1Status->getUserId()); + $this->assertEquals(true, $user1Status->getIsBackup()); + $this->assertEquals('Backup', $user1Status->getCustomMessage()); + } + } + public function testRestoreBackupStatuses(): void { $userStatus1 = new UserStatus(); $userStatus1->setUserId('_user1'); |