diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-04-28 15:39:38 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-04-30 14:48:36 +0200 |
commit | 29213b6136a4b2f71e5f981e9bc08e3e76128d4e (patch) | |
tree | 986bdf2bce27ff1c2b49828625c7f632d15cb865 /tests/lib/memcache | |
parent | d308ec4f0ea54e8cb0c99228a480da8cb7cf30a8 (diff) | |
download | nextcloud-server-29213b6136a4b2f71e5f981e9bc08e3e76128d4e.tar.gz nextcloud-server-29213b6136a4b2f71e5f981e9bc08e3e76128d4e.zip |
extends memcache with add, inc and dec
Diffstat (limited to 'tests/lib/memcache')
-rw-r--r-- | tests/lib/memcache/cache.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/lib/memcache/cache.php b/tests/lib/memcache/cache.php index e5ceae52fb0..80ad182b6bf 100644 --- a/tests/lib/memcache/cache.php +++ b/tests/lib/memcache/cache.php @@ -10,6 +10,11 @@ namespace Test\Memcache; abstract class Cache extends \Test_Cache { + /** + * @var \OCP\IMemcache cache; + */ + protected $instance; + public function testExistsAfterSet() { $this->assertFalse($this->instance->hasKey('foo')); $this->instance->set('foo', 'bar'); @@ -56,6 +61,37 @@ abstract class Cache extends \Test_Cache { $this->assertFalse($this->instance->hasKey('foo')); } + public function testAdd() { + $this->assertTrue($this->instance->add('foo', 'bar')); + $this->assertEquals('bar', $this->instance->get('foo')); + $this->assertFalse($this->instance->add('foo', 'asd')); + $this->assertEquals('bar', $this->instance->get('foo')); + } + + public function testInc() { + $this->assertEquals(1, $this->instance->inc('foo')); + $this->assertEquals(1, $this->instance->get('foo')); + $this->assertEquals(2, $this->instance->inc('foo')); + $this->assertEquals(12, $this->instance->inc('foo', 10)); + + $this->instance->set('foo', 'bar'); + $this->assertFalse($this->instance->inc('foo')); + $this->assertEquals('bar', $this->instance->get('foo')); + } + + public function testDec() { + $this->assertEquals(false, $this->instance->dec('foo')); + $this->instance->set('foo', 20); + $this->assertEquals(19, $this->instance->dec('foo')); + $this->assertEquals(19, $this->instance->get('foo')); + $this->assertEquals(9, $this->instance->dec('foo', 10)); + + $this->instance->set('foo', 'bar'); + $this->assertFalse($this->instance->dec('foo')); + $this->assertEquals('bar', $this->instance->get('foo')); + } + + protected function tearDown() { if ($this->instance) { $this->instance->clear(); |