Config::set('system', 'theme', 'system_theme');
}
+ /**
+ * @small
+ */
function testSimple() {
$this->assertNull($this->instance->get('value1'));
$this->assertNull($this->instance->get('value1'));
}
+ /**
+ * @small
+ */
function testClear() {
$value = 'ipsum lorum';
$this->instance->set('1_value1', $value . '1');
]);
}
+ /**
+ * @medium
+ */
function testTTL() {
$this->assertNull($this->instance->get('value1'));
$this->assertNull($this->instance->get('value1'));
}
+ /**
+ * @small
+ */
function testDifferentTypesInCache() {
// String test
$value = "foobar";
use Friendica\Core\Cache\CacheDriverFactory;
+/**
+ * @requires extension memcache
+ */
class MemcacheCacheDriverTest extends MemoryCacheTest
{
/**
protected function getInstance()
{
- if (class_exists('Memcache')) {
- try {
- $this->cache = CacheDriverFactory::create('memcache');
- } catch (\Exception $exception) {
- throw new \Exception("Memcache - TestCase failed: " . $exception->getMessage(), $exception->getCode(), $exception);
- }
- return $this->cache;
- } else {
- $this->markTestSkipped('Memcache driver isn\'t available');
- return null;
- }
+ $this->cache = CacheDriverFactory::create('memcache');
+ return $this->cache;
+
}
public function tearDown()
{
- if (class_exists('Memcache')) {
- $this->cache->clear(false);
- }
+ $this->cache->clear(false);
parent::tearDown();
}
}
use Friendica\Core\Cache\CacheDriverFactory;
+/**
+ * @requires extension memcached
+ */
class MemcachedCacheDriverTest extends MemoryCacheTest
{
/**
protected function getInstance()
{
- if (class_exists('Memcached')) {
- try {
- $this->cache = CacheDriverFactory::create('memcached');
- } catch (\Exception $exception) {
- throw new \Exception("Memcached - TestCase failed: " . $exception->getMessage(), $exception->getCode(), $exception);
- }
- return $this->cache;
- } else {
- $this->markTestSkipped('Memcached driver isn\'t available');
- return null;
- }
+ $this->cache = CacheDriverFactory::create('memcached');
+ return $this->cache;
}
public function tearDown()
{
- if (class_exists('Memcached')) {
- $this->cache->clear(false);
- }
+ $this->cache->clear(false);
parent::tearDown();
}
}
}
}
+ /**
+ * @small
+ */
function testCompareSet() {
$this->assertNull($this->instance->get('value1'));
$this->assertEquals($newValue, $received, 'Value not overwritten by compareSet');
}
+ /**
+ * @small
+ */
function testNegativeCompareSet() {
$this->assertNull($this->instance->get('value1'));
$this->assertEquals($value, $received, 'Value was wrongly overwritten by any other value');
}
+ /**
+ * @small
+ */
function testCompareDelete() {
$this->assertNull($this->instance->get('value1'));
$this->assertNull($this->instance->get('value1'), 'Value was not deleted by compareDelete');
}
+ /**
+ * @small
+ */
function testNegativeCompareDelete() {
$this->assertNull($this->instance->get('value1'));
$this->assertNull($this->instance->get('value1'), 'Value was wrongly NOT deleted by compareDelete');
}
+ /**
+ * @small
+ */
function testAdd() {
$this->assertNull($this->instance->get('value1'));
use Friendica\Core\Cache\CacheDriverFactory;
+/**
+ * @requires extension redis
+ */
class RedisCacheDriverTest extends MemoryCacheTest
{
/**
protected function getInstance()
{
- if (class_exists('Redis')) {
- try {
- $this->cache = CacheDriverFactory::create('redis');
- } catch (\Exception $exception) {
- throw new \Exception("Redis - TestCase failed: " . $exception->getMessage(), $exception->getCode(), $exception);
- }
- return $this->cache;
- } else {
- $this->markTestSkipped('Redis driver isn\'t available');
- return null;
- }
+ $this->cache = CacheDriverFactory::create('redis');
+ return $this->cache;
}
public function tearDown()
{
- if (class_exists('Redis')) {
- $this->cache->clear(false);
- }
+ $this->cache->clear(false);
parent::tearDown();
}
}
Config::set('system', 'theme', 'system_theme');
}
+ /**
+ * @small
+ */
public function testLock() {
$this->instance->acquireLock('foo', 1);
$this->assertTrue($this->instance->isLocked('foo'));
$this->assertFalse($this->instance->isLocked('bar'));
}
+ /**
+ * @small
+ */
public function testDoubleLock() {
$this->instance->acquireLock('foo', 1);
$this->assertTrue($this->instance->isLocked('foo'));
$this->assertTrue($this->instance->acquireLock('foo', 1));
}
+ /**
+ * @small
+ */
public function testReleaseLock() {
$this->instance->acquireLock('foo', 1);
$this->assertTrue($this->instance->isLocked('foo'));
$this->assertFalse($this->instance->isLocked('foo'));
}
+ /**
+ * @small
+ */
public function testReleaseAll() {
$this->instance->acquireLock('foo', 1);
$this->instance->acquireLock('bar', 1);
$this->assertFalse($this->instance->isLocked('nice'));
}
+ /**
+ * @small
+ */
public function testReleaseAfterUnlock() {
$this->instance->acquireLock('foo', 1);
$this->instance->acquireLock('bar', 1);
$this->assertFalse($this->instance->isLocked('nice'));
}
+ /**
+ * @medium
+ */
function testLockTTL() {
// TODO [nupplaphil] - Because of the Datetime-Utils for the database, we have to wait a FULL second between the checks to invalidate the db-locks/cache
use Friendica\Core\Cache\CacheDriverFactory;
use Friendica\Core\Lock\CacheLockDriver;
+/**
+ * @requires extension Memcache
+ */
class MemcacheCacheLockDriverTest extends LockTest
{
/**
protected function getInstance()
{
- if (class_exists('Memcache')) {
- try {
- $this->cache = CacheDriverFactory::create('memcache');
- } catch (\Exception $exception) {
- print "Memcache - TestCase failed: " . $exception->getMessage();
- throw new \Exception();
- }
- return new CacheLockDriver($this->cache);
- } else {
- $this->markTestSkipped('Memcache driver isn\'t available');
- return null;
- }
+ $this->cache = CacheDriverFactory::create('memcache');
+ return new CacheLockDriver($this->cache);
}
public function tearDown()
{
- if (class_exists('Memcache')) {
- $this->cache->clear();
- }
+ $this->cache->clear();
parent::tearDown();
}
}
use Friendica\Core\Cache\CacheDriverFactory;
use Friendica\Core\Lock\CacheLockDriver;
+/**
+ * @requires extension memcached
+ */
class MemcachedCacheLockDriverTest extends LockTest
{
/**
protected function getInstance()
{
- if (class_exists('Memcached')) {
- try {
- $this->cache = CacheDriverFactory::create('memcached');
- } catch (\Exception $exception) {
- print "Memcached - TestCase failed: " . $exception->getMessage();
- throw new \Exception();
- }
- return new CacheLockDriver($this->cache);
- } else {
- $this->markTestSkipped('Memcached driver isn\'t available');
- return null;
- }
+ $this->cache = CacheDriverFactory::create('memcached');
+ return new CacheLockDriver($this->cache);
}
public function tearDown()
{
- if (class_exists('Memcached')) {
- $this->cache->clear();
- }
+ $this->cache->clear();
parent::tearDown();
}
}
use Friendica\Core\Cache\CacheDriverFactory;
use Friendica\Core\Lock\CacheLockDriver;
+/**
+ * @requires extension redis
+ */
class RedisCacheLockDriverTest extends LockTest
{
/**
protected function getInstance()
{
- if (class_exists('Redis')) {
- try {
- $this->cache = CacheDriverFactory::create('redis');
- } catch (\Exception $exception) {
- print "Redis - TestCase failed: " . $exception->getMessage();
- throw new \Exception();
- }
- return new CacheLockDriver($this->cache);
- } else {
- $this->markTestSkipped('Redis driver isn\'t available');
- return null;
- }
+ $this->cache = CacheDriverFactory::create('redis');
+ return new CacheLockDriver($this->cache);
+
}
public function tearDown()
{
- if (class_exists('Redis')) {
- $this->cache->clear();
- }
+ $this->cache->clear();
parent::tearDown();
}
}