From: Robin Appelman Date: Tue, 16 Jul 2013 13:46:27 +0000 (+0200) Subject: memcache: some additional unit tests X-Git-Tag: v6.0.0alpha2~452^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8ad148feaf975481815b3f2413fc1fa34b3e8be7;p=nextcloud-server.git memcache: some additional unit tests --- diff --git a/tests/lib/memcache/apc.php b/tests/lib/memcache/apc.php index e3dccc09669..6b2a49470ba 100644 --- a/tests/lib/memcache/apc.php +++ b/tests/lib/memcache/apc.php @@ -1,31 +1,20 @@ . -* -*/ + * Copyright (c) 2013 Robin Appelman + * 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 index 00000000000..2c1dbc9d2f7 --- /dev/null +++ b/tests/lib/memcache/cache.php @@ -0,0 +1,36 @@ + + * 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(); + } + } +} diff --git a/tests/lib/memcache/memcached.php b/tests/lib/memcache/memcached.php index a0be047ed1f..4b38ae8ef3c 100644 --- a/tests/lib/memcache/memcached.php +++ b/tests/lib/memcache/memcached.php @@ -1,4 +1,5 @@ * 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()); } } diff --git a/tests/lib/memcache/xcache.php b/tests/lib/memcache/xcache.php index 48773533c89..f59afda3966 100644 --- a/tests/lib/memcache/xcache.php +++ b/tests/lib/memcache/xcache.php @@ -1,31 +1,20 @@ . - * + * Copyright (c) 2013 Robin Appelman + * 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()); } }