aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Memcache
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Memcache')
-rw-r--r--tests/lib/Memcache/APCuTest.php6
-rw-r--r--tests/lib/Memcache/ArrayCacheTest.php4
-rw-r--r--tests/lib/Memcache/CasTraitTest.php3
-rw-r--r--tests/lib/Memcache/FactoryTest.php20
-rw-r--r--tests/lib/Memcache/MemcachedTest.php8
-rw-r--r--tests/lib/Memcache/RedisTest.php14
6 files changed, 33 insertions, 22 deletions
diff --git a/tests/lib/Memcache/APCuTest.php b/tests/lib/Memcache/APCuTest.php
index cb465d1f07a..199bdf298f6 100644
--- a/tests/lib/Memcache/APCuTest.php
+++ b/tests/lib/Memcache/APCuTest.php
@@ -8,6 +8,8 @@
namespace Test\Memcache;
+use OC\Memcache\APCu;
+
/**
* @group Memcache
* @group APCu
@@ -16,11 +18,11 @@ class APCuTest extends Cache {
protected function setUp(): void {
parent::setUp();
- if (!\OC\Memcache\APCu::isAvailable()) {
+ if (!APCu::isAvailable()) {
$this->markTestSkipped('The APCu extension is not available.');
return;
}
- $this->instance = new \OC\Memcache\APCu($this->getUniqueID());
+ $this->instance = new APCu($this->getUniqueID());
}
public function testCasIntChanged(): void {
diff --git a/tests/lib/Memcache/ArrayCacheTest.php b/tests/lib/Memcache/ArrayCacheTest.php
index 42b548355eb..e71c821729c 100644
--- a/tests/lib/Memcache/ArrayCacheTest.php
+++ b/tests/lib/Memcache/ArrayCacheTest.php
@@ -8,12 +8,14 @@
namespace Test\Memcache;
+use OC\Memcache\ArrayCache;
+
/**
* @group Memcache
*/
class ArrayCacheTest extends Cache {
protected function setUp(): void {
parent::setUp();
- $this->instance = new \OC\Memcache\ArrayCache('');
+ $this->instance = new ArrayCache('');
}
}
diff --git a/tests/lib/Memcache/CasTraitTest.php b/tests/lib/Memcache/CasTraitTest.php
index 129819045f2..57000049cc7 100644
--- a/tests/lib/Memcache/CasTraitTest.php
+++ b/tests/lib/Memcache/CasTraitTest.php
@@ -7,6 +7,7 @@
namespace Test\Memcache;
+use OC\Memcache\ArrayCache;
use Test\TestCase;
/**
@@ -17,7 +18,7 @@ class CasTraitTest extends TestCase {
* @return \OC\Memcache\CasTrait
*/
private function getCache() {
- $sourceCache = new \OC\Memcache\ArrayCache();
+ $sourceCache = new ArrayCache();
$mock = $this->getMockForTrait('\OC\Memcache\CasTrait');
$mock->expects($this->any())
diff --git a/tests/lib/Memcache/FactoryTest.php b/tests/lib/Memcache/FactoryTest.php
index cbf908e0cc6..afd17081660 100644
--- a/tests/lib/Memcache/FactoryTest.php
+++ b/tests/lib/Memcache/FactoryTest.php
@@ -7,7 +7,9 @@
namespace Test\Memcache;
+use OC\Memcache\Factory;
use OC\Memcache\NullCache;
+use OCP\HintException;
use OCP\Profiler\IProfiler;
use Psr\Log\LoggerInterface;
@@ -61,27 +63,27 @@ class FactoryTest extends \Test\TestCase {
[
// local and distributed available
self::AVAILABLE1, self::AVAILABLE2, null,
- self::AVAILABLE1, self::AVAILABLE2, \OC\Memcache\Factory::NULL_CACHE
+ self::AVAILABLE1, self::AVAILABLE2, Factory::NULL_CACHE
],
[
// local and distributed null
null, null, null,
- \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE
+ Factory::NULL_CACHE, Factory::NULL_CACHE, Factory::NULL_CACHE
],
[
// local available, distributed null (most common scenario)
self::AVAILABLE1, null, null,
- self::AVAILABLE1, self::AVAILABLE1, \OC\Memcache\Factory::NULL_CACHE
+ self::AVAILABLE1, self::AVAILABLE1, Factory::NULL_CACHE
],
[
// locking cache available
null, null, self::AVAILABLE1,
- \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE, self::AVAILABLE1
+ Factory::NULL_CACHE, Factory::NULL_CACHE, self::AVAILABLE1
],
[
// locking cache unavailable: no exception here in the factory
null, null, self::UNAVAILABLE1,
- \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE, \OC\Memcache\Factory::NULL_CACHE
+ Factory::NULL_CACHE, Factory::NULL_CACHE, Factory::NULL_CACHE
]
];
}
@@ -110,7 +112,7 @@ class FactoryTest extends \Test\TestCase {
$expectedLocalCache, $expectedDistributedCache, $expectedLockingCache): void {
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$profiler = $this->getMockBuilder(IProfiler::class)->getMock();
- $factory = new \OC\Memcache\Factory(fn () => 'abc', $logger, $profiler, $localCache, $distributedCache, $lockingCache);
+ $factory = new Factory(fn () => 'abc', $logger, $profiler, $localCache, $distributedCache, $lockingCache);
$this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache));
$this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache));
$this->assertTrue(is_a($factory->createLocking(), $expectedLockingCache));
@@ -120,17 +122,17 @@ class FactoryTest extends \Test\TestCase {
* @dataProvider cacheUnavailableProvider
*/
public function testCacheNotAvailableException($localCache, $distributedCache): void {
- $this->expectException(\OCP\HintException::class);
+ $this->expectException(HintException::class);
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$profiler = $this->getMockBuilder(IProfiler::class)->getMock();
- new \OC\Memcache\Factory(fn () => 'abc', $logger, $profiler, $localCache, $distributedCache);
+ new Factory(fn () => 'abc', $logger, $profiler, $localCache, $distributedCache);
}
public function testCreateInMemory(): void {
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$profiler = $this->getMockBuilder(IProfiler::class)->getMock();
- $factory = new \OC\Memcache\Factory(fn () => 'abc', $logger, $profiler, null, null, null);
+ $factory = new Factory(fn () => 'abc', $logger, $profiler, null, null, null);
$cache = $factory->createInMemory();
$cache->set('test', 48);
diff --git a/tests/lib/Memcache/MemcachedTest.php b/tests/lib/Memcache/MemcachedTest.php
index 346530e191d..61e2f42e3d6 100644
--- a/tests/lib/Memcache/MemcachedTest.php
+++ b/tests/lib/Memcache/MemcachedTest.php
@@ -8,6 +8,8 @@
namespace Test\Memcache;
+use OC\Memcache\Memcached;
+
/**
* @group Memcache
* @group Memcached
@@ -16,10 +18,10 @@ class MemcachedTest extends Cache {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
- if (!\OC\Memcache\Memcached::isAvailable()) {
+ if (!Memcached::isAvailable()) {
self::markTestSkipped('The memcached extension is not available.');
}
- $instance = new \OC\Memcache\Memcached(self::getUniqueID());
+ $instance = new Memcached(self::getUniqueID());
if ($instance->set(self::getUniqueID(), self::getUniqueID()) === false) {
self::markTestSkipped('memcached server seems to be down.');
}
@@ -27,7 +29,7 @@ class MemcachedTest extends Cache {
protected function setUp(): void {
parent::setUp();
- $this->instance = new \OC\Memcache\Memcached($this->getUniqueID());
+ $this->instance = new Memcached($this->getUniqueID());
}
public function testClear(): void {
diff --git a/tests/lib/Memcache/RedisTest.php b/tests/lib/Memcache/RedisTest.php
index d76da03eb85..c1dcc954925 100644
--- a/tests/lib/Memcache/RedisTest.php
+++ b/tests/lib/Memcache/RedisTest.php
@@ -9,6 +9,8 @@
namespace Test\Memcache;
use OC\Memcache\Redis;
+use OCP\IConfig;
+use OCP\Server;
/**
* @group Memcache
@@ -23,24 +25,24 @@ class RedisTest extends Cache {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
- if (!\OC\Memcache\Redis::isAvailable()) {
+ if (!Redis::isAvailable()) {
self::markTestSkipped('The redis extension is not available.');
}
- if (\OC::$server->getConfig()->getSystemValue('redis', []) === []) {
+ if (Server::get(IConfig::class)->getSystemValue('redis', []) === []) {
self::markTestSkipped('Redis not configured in config.php');
}
$errorOccurred = false;
set_error_handler(
- function ($errno, $errstr) {
+ function ($errno, $errstr): void {
throw new \RuntimeException($errstr, 123456789);
},
E_WARNING
);
$instance = null;
try {
- $instance = new \OC\Memcache\Redis(self::getUniqueID());
+ $instance = new Redis(self::getUniqueID());
} catch (\RuntimeException $e) {
$errorOccurred = $e->getCode() === 123456789 ? $e->getMessage() : false;
}
@@ -60,11 +62,11 @@ class RedisTest extends Cache {
protected function setUp(): void {
parent::setUp();
- $this->instance = new \OC\Memcache\Redis($this->getUniqueID());
+ $this->instance = new Redis($this->getUniqueID());
}
public function testScriptHashes(): void {
- foreach (\OC\Memcache\Redis::LUA_SCRIPTS as $script) {
+ foreach (Redis::LUA_SCRIPTS as $script) {
$this->assertEquals(sha1($script[0]), $script[1]);
}
}