@@ -216,6 +216,27 @@ public function testExpiredLocksAreDeprecated() {
216216 self ::assertNotEmpty ($ deprecated );
217217 }
218218
219+ public function testRemoveLocks (): void {
220+ $ service = \OCP \Server::get (LockService::class);
221+ \OCP \Server::get (IConfig::class)->setAppValue (Application::APP_ID , ConfigService::LOCK_TIMEOUT , 30 );
222+ $ file = $ this ->loginAndGetUserFolder (self ::TEST_USER1 )->newFile ('test-expired-lock-is-deprecated ' , 'AAA ' );
223+ $ lock1 = $ this ->lockManager ->lock (new LockContext ($ file , ILock::TYPE_USER , self ::TEST_USER1 ));
224+ $ file2 = $ this ->loginAndGetUserFolder (self ::TEST_USER1 )->newFile ('test-expired-lock-is-deprecated-2 ' , 'AAA ' );
225+ $ lock2 = $ this ->lockManager ->lock (new LockContext ($ file2 , ILock::TYPE_USER , self ::TEST_USER1 ));
226+ $ this ->toTheFuture (3600 );
227+ $ mapToTokens = fn (ILock $ lock ) => $ lock ->getToken ();
228+ $ deprecated = array_map ($ mapToTokens , $ service ->getDeprecatedLocks ());
229+
230+ self ::assertContains ($ lock1 ->getToken (), $ deprecated );
231+ self ::assertContains ($ lock2 ->getToken (), $ deprecated );
232+
233+ $ service ->removeLocks ([$ lock1 , $ lock2 ]);
234+ $ deprecated = array_map ($ mapToTokens , $ service ->getDeprecatedLocks ());
235+
236+ self ::assertNotContains ($ lock1 ->getToken (), $ deprecated );
237+ self ::assertNotContains ($ lock2 ->getToken (), $ deprecated );
238+ }
239+
219240 public function testLockUserInfinite () {
220241 \OCP \Server::get (IConfig::class)->setAppValue (Application::APP_ID , ConfigService::LOCK_TIMEOUT , 0 );
221242 $ file = $ this ->loginAndGetUserFolder (self ::TEST_USER1 )
0 commit comments