Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More reliable user_status tests #48344

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@ public function testNoStatusYet(): void {
}

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 {
Expand Down Expand Up @@ -95,15 +98,29 @@ public function testCreateRestoreBackupAutomatically(): void {
'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(),
Expand Down
Loading