]> source.dussan.org Git - nextcloud-server.git/commitdiff
memcache: some additional unit tests
authorRobin Appelman <icewind@owncloud.com>
Tue, 16 Jul 2013 13:46:27 +0000 (15:46 +0200)
committerRobin Appelman <icewind@owncloud.com>
Tue, 16 Jul 2013 13:46:27 +0000 (15:46 +0200)
tests/lib/memcache/apc.php
tests/lib/memcache/cache.php [new file with mode: 0644]
tests/lib/memcache/memcached.php
tests/lib/memcache/xcache.php

index e3dccc096691176b2fbf906c62372160133b05f5..6b2a49470ba21d7391ae6920c2f83e33ff27222a 100644 (file)
@@ -1,31 +1,20 @@
 <?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/>.
-*
-*/
+ * 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 Test_Memcache_APC extends Test_Cache {
+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();
+               $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 (file)
index 0000000..2c1dbc9
--- /dev/null
@@ -0,0 +1,36 @@
+<?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 tearDown() {
+               if ($this->instance) {
+                       $this->instance->clear();
+               }
+       }
+}
index a0be047ed1fa28fbfa66f4a4ad198a6bb82cfc5c..4b38ae8ef3c54b3e92011ceb55b13b23efba0453 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
  * This file is licensed under the Affero General Public License version 3 or
@@ -6,12 +7,14 @@
  * See the COPYING-README file.
  */
 
-class Test_Memcache_Memcached extends Test_Cache {
+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();
+               $this->instance = new \OC\Memcache\Memcached(uniqid());
        }
 }
index 48773533c894fe8b1ba63c04a9065a74c72dccd4..f59afda396664ec1c63e94a7c37816a80cd21ba1 100644 (file)
@@ -1,31 +1,20 @@
 <?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/>.
- *
+ * 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.
  */
 
-class Test_Memcache_XCache extends Test_Cache {
+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();
+               $this->instance = new \OC\Memcache\XCache(uniqid());
        }
 }