summaryrefslogtreecommitdiffstats
path: root/tests/lib/memcache
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/memcache')
-rw-r--r--tests/lib/memcache/cache.php36
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();