In case of failure, PHPUnit seems to skip `tearDown`, so any useful
assertion messages cannot be shown because `tearDownAfterClass` is
throwing an error because of database usage.
This commit makes sure we also restore the database in
`tearDownAfterClass` to prevent the data root restoration to fail
This is necessary to categorize unit test and avoid duplicate test case execution - it also allows us to closely review unit test implementations to identify unnecessary db calls.
Instead of unlocking after the file operation, change exclusive locks
back to shared locks during post hooks, and unlock after that.
Also added unit tests to test locking in pre-hooks, during operation and
post-hooks.
Fixed code path for Webdav PUT of small files to use shared locks during
hook execution, and exclusive during the file operation
This makes it possible for versions to be copied by accessing the file
in a post_write hook.
The purpose of $originalStorage in unit tests was to remount the old
root.
However that storage itself is already wrapped by storage wrapper, so
remounting it would rewrap the storage several times.
This fix makes use of "loginAsUser()" and "logout()" from the TestCase
class to properly initialize and cleanup the FS as expected.