2013-07-16 13:46:27 +00:00
|
|
|
<?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;
|
|
|
|
|
2013-07-16 21:11:22 +00:00
|
|
|
abstract class Cache extends \Test_Cache {
|
2013-07-16 13:46:27 +00:00
|
|
|
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'));
|
|
|
|
}
|
|
|
|
|
2015-01-20 09:51:04 +00:00
|
|
|
public function testGetArrayAfterSet() {
|
|
|
|
$this->assertNull($this->instance->get('foo'));
|
|
|
|
$this->instance->set('foo', ['bar']);
|
|
|
|
$this->assertEquals(['bar'], $this->instance->get('foo'));
|
|
|
|
}
|
|
|
|
|
2013-07-16 13:46:27 +00:00
|
|
|
public function testDoesNotExistAfterRemove() {
|
|
|
|
$this->instance->set('foo', 'bar');
|
|
|
|
$this->instance->remove('foo');
|
|
|
|
$this->assertFalse($this->instance->hasKey('foo'));
|
|
|
|
}
|
|
|
|
|
2013-07-16 14:06:00 +00:00
|
|
|
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'));
|
|
|
|
}
|
|
|
|
|
2014-11-10 22:30:38 +00:00
|
|
|
protected function tearDown() {
|
2013-07-16 13:46:27 +00:00
|
|
|
if ($this->instance) {
|
|
|
|
$this->instance->clear();
|
|
|
|
}
|
2014-11-10 22:30:38 +00:00
|
|
|
|
|
|
|
parent::tearDown();
|
2013-07-16 13:46:27 +00:00
|
|
|
}
|
|
|
|
}
|