summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-11-15 00:57:30 +0100
committerRobin Appelman <icewind@owncloud.com>2012-11-15 00:57:30 +0100
commitcbcd9ba84ada830d91a6f1d7bee0ac59762835ed (patch)
treeb5c71d4d517f915d5c22979947796aba06021ce6 /tests
parentbf2ac9f113d41dc944f42d1516649a3a72e88a65 (diff)
downloadnextcloud-server-cbcd9ba84ada830d91a6f1d7bee0ac59762835ed.tar.gz
nextcloud-server-cbcd9ba84ada830d91a6f1d7bee0ac59762835ed.zip
allow storage backends to implement custom permission management
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/cache/permissions.php45
-rw-r--r--tests/lib/files/cache/scanner.php3
-rw-r--r--tests/lib/files/cache/watcher.php3
-rw-r--r--tests/lib/files/view.php3
4 files changed, 33 insertions, 21 deletions
diff --git a/tests/lib/files/cache/permissions.php b/tests/lib/files/cache/permissions.php
index 4d47929a3ee..56dbbc4518e 100644
--- a/tests/lib/files/cache/permissions.php
+++ b/tests/lib/files/cache/permissions.php
@@ -9,39 +9,48 @@
namespace Test\Files\Cache;
class Permissions extends \PHPUnit_Framework_TestCase {
+ /***
+ * @var \OC\Files\Cache\Permissions $permissionsCache
+ */
+ private $permissionsCache;
+
+ function setUp(){
+ $this->permissionsCache=new \OC\Files\Cache\Permissions('dummy');
+ }
+
function testSimple() {
$ids = range(1, 10);
$user = uniqid();
- $this->assertEquals(-1, \OC\Files\Cache\Permissions::get(1, $user));
- \OC\Files\Cache\Permissions::set(1, $user, 1);
- $this->assertEquals(1, \OC\Files\Cache\Permissions::get(1, $user));
- $this->assertEquals(-1, \OC\Files\Cache\Permissions::get(2, $user));
- $this->assertEquals(-1, \OC\Files\Cache\Permissions::get(1, $user . '2'));
+ $this->assertEquals(-1, $this->permissionsCache->get(1, $user));
+ $this->permissionsCache->set(1, $user, 1);
+ $this->assertEquals(1, $this->permissionsCache->get(1, $user));
+ $this->assertEquals(-1, $this->permissionsCache->get(2, $user));
+ $this->assertEquals(-1, $this->permissionsCache->get(1, $user . '2'));
- \OC\Files\Cache\Permissions::set(1, $user, 2);
- $this->assertEquals(2, \OC\Files\Cache\Permissions::get(1, $user));
+ $this->permissionsCache->set(1, $user, 2);
+ $this->assertEquals(2, $this->permissionsCache->get(1, $user));
- \OC\Files\Cache\Permissions::set(2, $user, 1);
- $this->assertEquals(1, \OC\Files\Cache\Permissions::get(2, $user));
+ $this->permissionsCache->set(2, $user, 1);
+ $this->assertEquals(1, $this->permissionsCache->get(2, $user));
- \OC\Files\Cache\Permissions::remove(1, $user);
- $this->assertEquals(-1, \OC\Files\Cache\Permissions::get(1, $user));
- \OC\Files\Cache\Permissions::remove(1, $user . '2');
- $this->assertEquals(1, \OC\Files\Cache\Permissions::get(2, $user));
+ $this->permissionsCache->remove(1, $user);
+ $this->assertEquals(-1, $this->permissionsCache->get(1, $user));
+ $this->permissionsCache->remove(1, $user . '2');
+ $this->assertEquals(1, $this->permissionsCache->get(2, $user));
$expected = array();
foreach ($ids as $id) {
- \OC\Files\Cache\Permissions::set($id, $user, 10 + $id);
+ $this->permissionsCache->set($id, $user, 10 + $id);
$expected[$id] = 10 + $id;
}
- $this->assertEquals($expected, \OC\Files\Cache\Permissions::getMultiple($ids, $user));
+ $this->assertEquals($expected, $this->permissionsCache->getMultiple($ids, $user));
- \OC\Files\Cache\Permissions::removeMultiple(array(10, 9), $user);
+ $this->permissionsCache->removeMultiple(array(10, 9), $user);
unset($expected[9]);
unset($expected[10]);
- $this->assertEquals($expected, \OC\Files\Cache\Permissions::getMultiple($ids, $user));
+ $this->assertEquals($expected, $this->permissionsCache->getMultiple($ids, $user));
- \OC\Files\Cache\Permissions::removeMultiple($ids, $user);
+ $this->permissionsCache->removeMultiple($ids, $user);
}
}
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php
index f784a82dada..c53da92727c 100644
--- a/tests/lib/files/cache/scanner.php
+++ b/tests/lib/files/cache/scanner.php
@@ -112,7 +112,8 @@ class Scanner extends \UnitTestCase {
function tearDown() {
$ids = $this->cache->getAll();
- \OC\Files\Cache\Permissions::removeMultiple($ids, \OC_User::getUser());
+ $permissionsCache = $this->storage->getPermissionsCache();
+ $permissionsCache->removeMultiple($ids, \OC_User::getUser());
$this->cache->clear();
}
}
diff --git a/tests/lib/files/cache/watcher.php b/tests/lib/files/cache/watcher.php
index a7076d9b0b5..0125dd843b9 100644
--- a/tests/lib/files/cache/watcher.php
+++ b/tests/lib/files/cache/watcher.php
@@ -23,7 +23,8 @@ class Watcher extends \PHPUnit_Framework_TestCase {
foreach ($this->storages as $storage) {
$cache = $storage->getCache();
$ids = $cache->getAll();
- \OC\Files\Cache\Permissions::removeMultiple($ids, \OC_User::getUser());
+ $permissionsCache = $storage->getPermissionsCache();
+ $permissionsCache->removeMultiple($ids, \OC_User::getUser());
$cache->clear();
}
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index fa562cb15cd..a173094b1cc 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -21,7 +21,8 @@ class View extends \PHPUnit_Framework_TestCase {
foreach ($this->storages as $storage) {
$cache = $storage->getCache();
$ids = $cache->getAll();
- \OC\Files\Cache\Permissions::removeMultiple($ids, \OC_User::getUser());
+ $permissionsCache = $storage->getPermissionsCache();
+ $permissionsCache->removeMultiple($ids, \OC_User::getUser());
$cache->clear();
}
}