From ec6ed0cf742a5e72fe1bdd135274af9aef1b2534 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 24 Sep 2024 07:00:19 +0200 Subject: [PATCH] fix(tests): Make timing test more reliable Signed-off-by: Joas Schilling --- .../Integration/Service/StatusServiceIntegrationTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/user_status/tests/Integration/Service/StatusServiceIntegrationTest.php b/apps/user_status/tests/Integration/Service/StatusServiceIntegrationTest.php index a035422087b..d979960f7c2 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 {