test(dav): add clarifying comments to testPutLocking test

Signed-off-by: Josh <josh.t.richards@gmail.com>
This commit is contained in:
Josh 2026-05-17 10:49:00 -04:00 committed by GitHub
parent 3ab1bd4549
commit 2d524128c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -800,7 +800,13 @@ class FileTest extends TestCase {
}
/**
* Test whether locks are set before and after the operation
* Test that PUT keeps hook-time lock semantics compatible:
* - pre-write hooks run while the file is shared-locked
* - post-write hooks also run while the file is shared-locked
*
* Post-write hooks are expected to observe a fully finalized file state,
* but should still be able to access the file without exclusive-lock
* contention.
*/
public function testPutLocking(): void {
$view = new View('/' . $this->user . '/files/');
@ -832,8 +838,8 @@ class FileTest extends TestCase {
$wasLockedPost = false;
$eventHandler = $this->createMock(EventHandlerMock::class);
// both pre and post hooks might need access to the file,
// so only shared lock is acceptable
// Pre-write hooks should run under a shared lock so observers can safely
// inspect the target while the write is in progress.
$eventHandler->expects($this->once())
->method('writeCallback')
->willReturnCallback(
@ -842,6 +848,10 @@ class FileTest extends TestCase {
$wasLockedPre = $wasLockedPre && !$this->isFileLocked($view, $path, ILockingProvider::LOCK_EXCLUSIVE);
}
);
// Post-write hooks should also run under a shared lock. They are expected to
// see fully finalized metadata/state, but still be able to access the file
// during the callback.
$eventHandler->expects($this->once())
->method('postWriteCallback')
->willReturnCallback(
@ -872,8 +882,8 @@ class FileTest extends TestCase {
// afterMethod unlocks
$view->unlockFile($path, ILockingProvider::LOCK_SHARED);
$this->assertTrue($wasLockedPre, 'File was locked during pre-hooks');
$this->assertTrue($wasLockedPost, 'File was locked during post-hooks');
$this->assertTrue($wasLockedPre, 'File was shared-locked during pre-hooks');
$this->assertTrue($wasLockedPost, 'File was shared-locked during post-hooks');
$this->assertFalse(
$this->isFileLocked($view, $path, ILockingProvider::LOCK_SHARED),