Skip to content

Commit bdcdd3e

Browse files
committed
test(timeout): locks are deprecated after expiry
Signed-off-by: Max <[email protected]>
1 parent 9c04f69 commit bdcdd3e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/Feature/LockFeatureTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
use OC\Files\Lock\LockManager;
88
use OCA\FilesLock\AppInfo\Application;
99
use OCA\FilesLock\Service\ConfigService;
10+
use OCA\FilesLock\Service\LockService;
1011
use OCP\AppFramework\Utility\ITimeFactory;
1112
use OCP\Files\IRootFolder;
1213
use OCP\Files\Lock\ILock;
1314
use OCP\Files\Lock\ILockManager;
1415
use OCP\Files\Lock\LockContext;
16+
use OCP\IConfig;
1517
use OCP\Lock\ManuallyLockedException;
1618
use OCP\Share\IManager as IShareManager;
1719
use OCP\Share\IShare;
@@ -195,6 +197,16 @@ public function testLockUserExpire() {
195197
self::assertEquals('CCC', $file->getContent());
196198
}
197199

200+
public function testExpiredLocksAreDeprecated() {
201+
\OCP\Server::get(IConfig::class)->setAppValue(Application::APP_ID, ConfigService::LOCK_TIMEOUT, 30);
202+
$file = $this->loginAndGetUserFolder(self::TEST_USER1)
203+
->newFile('test-expired-lock-is-deprecated', 'AAA');
204+
$this->lockManager->lock(new LockContext($file, ILock::TYPE_USER, self::TEST_USER1));
205+
$this->toTheFuture(3600);
206+
$deprecated = \OCP\Server::get(LockService::class)->getDeprecatedLocks();
207+
self::assertNotEmpty($deprecated);
208+
}
209+
198210
public function testLockUserInfinite() {
199211
\OC::$server->getConfig()->setAppValue(Application::APP_ID, ConfigService::LOCK_TIMEOUT, 0);
200212
$file = $this->loginAndGetUserFolder(self::TEST_USER1)

0 commit comments

Comments
 (0)