summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoricewind1991 <icewind1991@gmail.com>2013-07-16 13:25:07 -0700
committericewind1991 <icewind1991@gmail.com>2013-07-16 13:25:07 -0700
commite09ffb6f57439353e992af516d47b170272cbbae (patch)
treef8ea1149f95de72ee785bd5571380724830523a5 /tests
parent285f288cf344625dbddd3c6e4bacb9df1ddb6ce0 (diff)
parentdc1a17b6f486c565ff5b30a6446421f1436355af (diff)
downloadnextcloud-server-e09ffb6f57439353e992af516d47b170272cbbae.tar.gz
nextcloud-server-e09ffb6f57439353e992af516d47b170272cbbae.zip
Merge pull request #2395 from owncloud/cache
Seperate the memory based cache and file based cache in OC_Cache
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/cache/apc.php35
-rw-r--r--tests/lib/cache/xcache.php31
-rw-r--r--tests/lib/memcache/apc.php20
-rw-r--r--tests/lib/memcache/cache.php58
-rw-r--r--tests/lib/memcache/memcached.php20
-rw-r--r--tests/lib/memcache/xcache.php20
6 files changed, 118 insertions, 66 deletions
diff --git a/tests/lib/cache/apc.php b/tests/lib/cache/apc.php
deleted file mode 100644
index bb5eb483dbf..00000000000
--- a/tests/lib/cache/apc.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-/**
-* ownCloud
-*
-* @author Robin Appelman
-* @copyright 2012 Robin Appelman icewind@owncloud.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-class Test_Cache_APC extends Test_Cache {
- public function setUp() {
- if(!extension_loaded('apc')) {
- $this->markTestSkipped('The apc extension is not available.');
- return;
- }
- if(!ini_get('apc.enable_cli') && OC::$CLI) {
- $this->markTestSkipped('apc not available in CLI.');
- return;
- }
- $this->instance=new OC_Cache_APC();
- }
-}
diff --git a/tests/lib/cache/xcache.php b/tests/lib/cache/xcache.php
deleted file mode 100644
index 43bed2db037..00000000000
--- a/tests/lib/cache/xcache.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
-* ownCloud
-*
-* @author Robin Appelman
-* @copyright 2012 Robin Appelman icewind@owncloud.com
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-class Test_Cache_XCache extends Test_Cache {
- public function setUp() {
- if(!function_exists('xcache_get')) {
- $this->markTestSkipped('The xcache extension is not available.');
- return;
- }
- $this->instance=new OC_Cache_XCache();
- }
-}
diff --git a/tests/lib/memcache/apc.php b/tests/lib/memcache/apc.php
new file mode 100644
index 00000000000..6b2a49470ba
--- /dev/null
+++ b/tests/lib/memcache/apc.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Memcache;
+
+class APC extends Cache {
+ public function setUp() {
+ if(!\OC\Memcache\APC::isAvailable()) {
+ $this->markTestSkipped('The apc extension is not available.');
+ return;
+ }
+ $this->instance=new \OC\Memcache\APC(uniqid());
+ }
+}
diff --git a/tests/lib/memcache/cache.php b/tests/lib/memcache/cache.php
new file mode 100644
index 00000000000..e2643b9fcd9
--- /dev/null
+++ b/tests/lib/memcache/cache.php
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Memcache;
+
+class Cache extends \Test_Cache {
+ public function testExistsAfterSet() {
+ $this->assertFalse($this->instance->hasKey('foo'));
+ $this->instance->set('foo', 'bar');
+ $this->assertTrue($this->instance->hasKey('foo'));
+ }
+
+ public function testGetAfterSet() {
+ $this->assertNull($this->instance->get('foo'));
+ $this->instance->set('foo', 'bar');
+ $this->assertEquals('bar', $this->instance->get('foo'));
+ }
+
+ public function testDoesNotExistAfterRemove() {
+ $this->instance->set('foo', 'bar');
+ $this->instance->remove('foo');
+ $this->assertFalse($this->instance->hasKey('foo'));
+ }
+
+ public function testArrayAccessSet() {
+ $this->instance['foo'] = 'bar';
+ $this->assertEquals('bar', $this->instance->get('foo'));
+ }
+
+ public function testArrayAccessGet() {
+ $this->instance->set('foo', 'bar');
+ $this->assertEquals('bar', $this->instance['foo']);
+ }
+
+ public function testArrayAccessExists() {
+ $this->assertFalse(isset($this->instance['foo']));
+ $this->instance->set('foo', 'bar');
+ $this->assertTrue(isset($this->instance['foo']));
+ }
+
+ public function testArrayAccessUnset() {
+ $this->instance->set('foo', 'bar');
+ unset($this->instance['foo']);
+ $this->assertFalse($this->instance->hasKey('foo'));
+ }
+
+ public function tearDown() {
+ if ($this->instance) {
+ $this->instance->clear();
+ }
+ }
+}
diff --git a/tests/lib/memcache/memcached.php b/tests/lib/memcache/memcached.php
new file mode 100644
index 00000000000..4b38ae8ef3c
--- /dev/null
+++ b/tests/lib/memcache/memcached.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Memcache;
+
+class Memcached extends Cache {
+ public function setUp() {
+ if (!\OC\Memcache\Memcached::isAvailable()) {
+ $this->markTestSkipped('The memcached extension is not available.');
+ return;
+ }
+ $this->instance = new \OC\Memcache\Memcached(uniqid());
+ }
+}
diff --git a/tests/lib/memcache/xcache.php b/tests/lib/memcache/xcache.php
new file mode 100644
index 00000000000..f59afda3966
--- /dev/null
+++ b/tests/lib/memcache/xcache.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test\Memcache;
+
+class XCache extends Cache {
+ public function setUp() {
+ if (!\OC\Memcache\XCache::isAvailable()) {
+ $this->markTestSkipped('The xcache extension is not available.');
+ return;
+ }
+ $this->instance = new \OC\Memcache\XCache(uniqid());
+ }
+}