Skip to content

Commit

Permalink
fixup! feat(rooms): add option to automatically lock public and group…
Browse files Browse the repository at this point in the history
… rooms if they are inactive
  • Loading branch information
miaulalala committed Nov 21, 2024
1 parent 83c0eb8 commit 5004c66
Showing 1 changed file with 35 additions and 29 deletions.
64 changes: 35 additions & 29 deletions tests/php/BackgroundJob/LockInactiveRoomsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,29 @@ public function setUp(): void {
}

public function testNotEnabled(): void {
$this->appConfig->expects(self::exactly(2))
->willReturnMap([
0,
false
]);
$this->appConfig->expects(self::once())
->method('getInactiveLockTime')
->willReturn(0);
$this->appConfig->expects(self::once())
->method('enableLobbyOnLockedRooms')
->willReturn(false);
$this->timeFactory->expects(self::never())
->method(self::anything());
$this->roomService->expects(self::never())
->method(self::anything());
$this->logger->expects(self::never())
->method(self::anything());

$this->job->run();
$this->job->run('t');
}

public function testNoRooms(): void {
$this->appConfig->expects(self::exactly(2))
->willReturnMap([
'getInactiveLockTime', 365,
'enableLobbyOnLockedRooms', false
]);
$this->appConfig->expects(self::once())
->method('getInactiveLockTime')
->willReturn(123);
$this->appConfig->expects(self::once())
->method('enableLobbyOnLockedRooms')
->willReturn(false);
$this->timeFactory->expects(self::once())
->method('getTime');
$this->timeFactory->expects(self::once())
Expand All @@ -74,26 +76,28 @@ public function testNoRooms(): void {
$this->logger->expects(self::never())
->method(self::anything());

$this->job->run();
$this->job->run('t');

}

public function testLockRooms(): void {
$rooms = [
$this->createConfiguredMock(Room::class, [
'getReadOnly' => false,
'getReadOnly' => 0,
'getType' => Room::TYPE_PUBLIC,
]),
$this->createConfiguredMock(Room::class, [
'getReadOnly' => false,
'getReadOnly' => 0,
'getType' => Room::TYPE_GROUP,
]),
];

$this->appConfig->expects(self::exactly(2))
->willReturnMap([
365,
false
]);
$this->appConfig->expects(self::once())
->method('getInactiveLockTime')
->willReturn(123);
$this->appConfig->expects(self::once())
->method('enableLobbyOnLockedRooms')
->willReturn(false);
$this->timeFactory->expects(self::once())
->method('getTime');
$this->timeFactory->expects(self::once())
Expand All @@ -108,29 +112,31 @@ public function testLockRooms(): void {
$this->logger->expects(self::exactly(2))
->method('debug');

$this->job->run();
$this->job->run('t');

}

public function testLockRoomsAndEnableLobby(): void {
$rooms = [
$this->createConfiguredMock(Room::class, [
'getReadOnly' => false,
'getReadOnly' => 0,
'getType' => Room::TYPE_PUBLIC,
]),
$this->createConfiguredMock(Room::class, [
'getReadOnly' => false,
'getReadOnly' => 0,
'getType' => Room::TYPE_GROUP,
]),
];

$this->appConfig->expects(self::exactly(2))
->willReturnMap([
365,
true
]);
$this->appConfig->expects(self::once())
->method('getInactiveLockTime')
->willReturn(123);
$this->appConfig->expects(self::once())
->method('enableLobbyOnLockedRooms')
->willReturn(true);
$this->timeFactory->expects(self::once())
->method('getTime');
$this->timeFactory->expects(self::once())
$this->timeFactory->expects(self::any())
->method('getDateTime');
$this->roomService->expects(self::once())
->method('getInactiveRooms')
Expand All @@ -142,6 +148,6 @@ public function testLockRoomsAndEnableLobby(): void {
$this->logger->expects(self::exactly(4))
->method('debug');

$this->job->run();
$this->job->run('t');
}
}

0 comments on commit 5004c66

Please sign in to comment.