2013-03-17 16:01:10 +01:00
|
|
|
<?php
|
2013-07-16 15:46:27 +02:00
|
|
|
|
2013-03-17 16:01:10 +01:00
|
|
|
/**
|
2024-05-10 15:09:14 +02:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2013-03-17 16:01:10 +01:00
|
|
|
*/
|
|
|
|
|
2013-07-16 15:46:27 +02:00
|
|
|
namespace Test\Memcache;
|
|
|
|
|
2023-01-20 15:49:15 +01:00
|
|
|
/**
|
|
|
|
* @group Memcache
|
|
|
|
* @group Memcached
|
|
|
|
*/
|
2016-05-20 15:38:20 +02:00
|
|
|
class MemcachedTest extends Cache {
|
2020-04-10 16:51:06 +02:00
|
|
|
public static function setUpBeforeClass(): void {
|
2014-11-10 23:30:38 +01:00
|
|
|
parent::setUpBeforeClass();
|
|
|
|
|
2013-12-09 14:31:35 +01:00
|
|
|
if (!\OC\Memcache\Memcached::isAvailable()) {
|
|
|
|
self::markTestSkipped('The memcached extension is not available.');
|
|
|
|
}
|
2014-12-02 13:51:36 +01:00
|
|
|
$instance = new \OC\Memcache\Memcached(self::getUniqueID());
|
|
|
|
if ($instance->set(self::getUniqueID(), self::getUniqueID()) === false) {
|
2013-12-09 01:02:42 +01:00
|
|
|
self::markTestSkipped('memcached server seems to be down.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 16:40:38 +01:00
|
|
|
protected function setUp(): void {
|
2014-11-10 23:30:38 +01:00
|
|
|
parent::setUp();
|
2014-12-02 13:51:36 +01:00
|
|
|
$this->instance = new \OC\Memcache\Memcached($this->getUniqueID());
|
2013-03-17 16:01:10 +01:00
|
|
|
}
|
2015-09-05 20:02:49 +01:00
|
|
|
|
|
|
|
public function testClear(): void {
|
|
|
|
// Memcached is sometimes broken with clear(), so we don't test it thoroughly
|
2020-10-05 15:12:57 +02:00
|
|
|
$value = 'ipsum lorum';
|
2015-09-05 20:02:49 +01:00
|
|
|
$this->instance->set('1_value1', $value);
|
|
|
|
$this->instance->set('1_value2', $value);
|
|
|
|
$this->instance->set('2_value1', $value);
|
|
|
|
$this->instance->set('3_value1', $value);
|
|
|
|
|
|
|
|
$this->assertTrue($this->instance->clear('1_'));
|
|
|
|
|
|
|
|
$this->assertFalse($this->instance->hasKey('1_value1'));
|
|
|
|
$this->assertFalse($this->instance->hasKey('1_value2'));
|
|
|
|
//$this->assertTrue($this->instance->hasKey('2_value1'));
|
|
|
|
//$this->assertTrue($this->instance->hasKey('3_value1'));
|
|
|
|
|
|
|
|
$this->assertTrue($this->instance->clear());
|
|
|
|
|
|
|
|
$this->assertFalse($this->instance->hasKey('1_value1'));
|
|
|
|
$this->assertFalse($this->instance->hasKey('1_value2'));
|
|
|
|
$this->assertFalse($this->instance->hasKey('2_value1'));
|
|
|
|
$this->assertFalse($this->instance->hasKey('3_value1'));
|
|
|
|
}
|
2013-03-17 16:01:10 +01:00
|
|
|
}
|