]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(tests): Make timing test more reliable
authorJoas Schilling <coding@schilljs.com>
Tue, 24 Sep 2024 05:00:19 +0000 (07:00 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 25 Sep 2024 06:35:19 +0000 (08:35 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/user_status/tests/Integration/Service/StatusServiceIntegrationTest.php

index a035422087b4ec9f378659b817c6ba7fd08e219a..d979960f7c2bd5957ee08d229b613ca9ee5d931a 100644 (file)
@@ -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 {