aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-09-25 09:13:29 +0200
committerGitHub <noreply@github.com>2024-09-25 09:13:29 +0200
commit62c033e4ca25c958d649e0a1842df78a7f985d44 (patch)
treec03bd9f24982a5b58d51f14f2c07f775b2003d29
parent2ff103cb877aa2305590c343d6dee4e0b7d78a4d (diff)
parent79084d577e212ba60fbd9a2f87af9a28b3cf2832 (diff)
downloadnextcloud-server-62c033e4ca25c958d649e0a1842df78a7f985d44.tar.gz
nextcloud-server-62c033e4ca25c958d649e0a1842df78a7f985d44.zip
Merge pull request #48344 from nextcloud/bugfix/noid/more-reliable-tests
More reliable user_status tests
-rw-r--r--apps/user_status/tests/Integration/Service/StatusServiceIntegrationTest.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/apps/user_status/tests/Integration/Service/StatusServiceIntegrationTest.php b/apps/user_status/tests/Integration/Service/StatusServiceIntegrationTest.php
index a035422087b..65b07997e82 100644
--- a/apps/user_status/tests/Integration/Service/StatusServiceIntegrationTest.php
+++ b/apps/user_status/tests/Integration/Service/StatusServiceIntegrationTest.php
@@ -42,17 +42,20 @@ class StatusServiceIntegrationTest extends TestCase {
}
public function testCustomStatusMessageTimestamp(): void {
+ $before = time();
$this->service->setCustomMessage(
'test123',
'🍕',
'Lunch',
null,
);
+ $after = time();
$status = $this->service->findByUserId('test123');
self::assertSame('Lunch', $status->getCustomMessage());
- self::assertGreaterThanOrEqual(time(), $status->getStatusMessageTimestamp());
+ self::assertGreaterThanOrEqual($before, $status->getStatusMessageTimestamp());
+ self::assertLessThanOrEqual($after, $status->getStatusMessageTimestamp());
}
public function testOnlineStatusKeepsMessageTimestamp(): void {
@@ -95,15 +98,29 @@ class StatusServiceIntegrationTest extends TestCase {
'meeting',
true,
);
+
self::assertSame(
'meeting',
$this->service->findByUserId('test123')->getMessageId(),
);
+ self::assertSame(
+ IUserStatus::ONLINE,
+ $this->service->findByUserId('_test123')->getStatus(),
+ );
- $this->service->revertUserStatus(
+ $revertedStatus = $this->service->revertUserStatus(
'test123',
'meeting',
);
+
+ self::assertNotNull($revertedStatus, 'Status should have been reverted');
+
+ try {
+ $this->service->findByUserId('_test123');
+ $this->fail('Expected DoesNotExistException() to be thrown when finding backup status after reverting');
+ } catch (DoesNotExistException) {
+ }
+
self::assertSame(
IUserStatus::ONLINE,
$this->service->findByUserId('test123')->getStatus(),