summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2015-07-24 14:12:50 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-09-14 20:35:33 +0200
commit17b671ee253bd232c18f9e27e4ee75b25f791296 (patch)
tree78fcbb8a173c28119ec088c9aa631541096eb894
parente612d3123f2b3d6ffd6d0e8b4da331cc5c6a8b3b (diff)
downloadnextcloud-server-17b671ee253bd232c18f9e27e4ee75b25f791296.tar.gz
nextcloud-server-17b671ee253bd232c18f9e27e4ee75b25f791296.zip
adjust tests to handle before/after locking
-rw-r--r--tests/lib/connector/sabre/file.php48
1 files changed, 43 insertions, 5 deletions
diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php
index 246f7f6d0a2..835ca2ed242 100644
--- a/tests/lib/connector/sabre/file.php
+++ b/tests/lib/connector/sabre/file.php
@@ -114,7 +114,7 @@ class File extends \Test\TestCase {
$view->expects($this->atLeastOnce())
->method('resolvePath')
->will($this->returnCallback(
- function($path) use ($storage){
+ function ($path) use ($storage) {
return [$storage, $path];
}
));
@@ -172,7 +172,7 @@ class File extends \Test\TestCase {
$view->expects($this->atLeastOnce())
->method('resolvePath')
->will($this->returnCallback(
- function($path) use ($storage){
+ function ($path) use ($storage) {
return [$storage, $path];
}
));
@@ -249,7 +249,15 @@ class File extends \Test\TestCase {
$file = new \OC\Connector\Sabre\File($view, $info);
- return $file->put($this->getStream('test data'));
+ // beforeMethod locks
+ $view->lockFile($path, ILockingProvider::LOCK_SHARED);
+
+ $result = $file->put($this->getStream('test data'));
+
+ // afterMethod unlocks
+ $view->unlockFile($path, ILockingProvider::LOCK_SHARED);
+
+ return $result;
}
/**
@@ -431,7 +439,13 @@ class File extends \Test\TestCase {
// action
$thrown = false;
try {
+ // beforeMethod locks
+ $view->lockFile('/test.txt', ILockingProvider::LOCK_SHARED);
+
$file->put($this->getStream('test data'));
+
+ // afterMethod unlocks
+ $view->unlockFile('/test.txt', ILockingProvider::LOCK_SHARED);
} catch (\Sabre\DAV\Exception\BadRequest $e) {
$thrown = true;
}
@@ -458,7 +472,13 @@ class File extends \Test\TestCase {
// action
$thrown = false;
try {
+ // beforeMethod locks
+ $view->lockFile($info->getPath(), ILockingProvider::LOCK_SHARED);
+
$file->put($this->getStream('test data'));
+
+ // afterMethod unlocks
+ $view->unlockFile($info->getPath(), ILockingProvider::LOCK_SHARED);
} catch (\OC\Connector\Sabre\Exception\FileLocked $e) {
$thrown = true;
}
@@ -519,7 +539,13 @@ class File extends \Test\TestCase {
// action
$thrown = false;
try {
+ // beforeMethod locks
+ $view->lockFile($info->getPath(), ILockingProvider::LOCK_SHARED);
+
$file->put($this->getStream('test data'));
+
+ // afterMethod unlocks
+ $view->unlockFile($info->getPath(), ILockingProvider::LOCK_SHARED);
} catch (\OC\Connector\Sabre\Exception\InvalidPath $e) {
$thrown = true;
}
@@ -577,7 +603,13 @@ class File extends \Test\TestCase {
// action
$thrown = false;
try {
+ // beforeMethod locks
+ $view->lockFile($info->getPath(), ILockingProvider::LOCK_SHARED);
+
$file->put($this->getStream('test data'));
+
+ // afterMethod unlocks
+ $view->unlockFile($info->getPath(), ILockingProvider::LOCK_SHARED);
} catch (\Sabre\DAV\Exception\BadRequest $e) {
$thrown = true;
}
@@ -702,7 +734,7 @@ class File extends \Test\TestCase {
$eventHandler->expects($this->once())
->method('writeCallback')
->will($this->returnCallback(
- function() use ($view, $path, &$wasLockedPre){
+ function () use ($view, $path, &$wasLockedPre) {
$wasLockedPre = $this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_SHARED);
$wasLockedPre = $wasLockedPre && !$this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE);
}
@@ -710,7 +742,7 @@ class File extends \Test\TestCase {
$eventHandler->expects($this->once())
->method('postWriteCallback')
->will($this->returnCallback(
- function() use ($view, $path, &$wasLockedPost){
+ function () use ($view, $path, &$wasLockedPost) {
$wasLockedPost = $this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_SHARED);
$wasLockedPost = $wasLockedPost && !$this->isFileLocked($view, $path, \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE);
}
@@ -729,8 +761,14 @@ class File extends \Test\TestCase {
'postWriteCallback'
);
+ // beforeMethod locks
+ $view->lockFile($path, ILockingProvider::LOCK_SHARED);
+
$this->assertNotEmpty($file->put($this->getStream('test data')));
+ // 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');