You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MemcachedTest.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\Memcache;
  9. class MemcachedTest extends Cache {
  10. static public function setUpBeforeClass() {
  11. parent::setUpBeforeClass();
  12. if (!\OC\Memcache\Memcached::isAvailable()) {
  13. self::markTestSkipped('The memcached extension is not available.');
  14. }
  15. $instance = new \OC\Memcache\Memcached(self::getUniqueID());
  16. if ($instance->set(self::getUniqueID(), self::getUniqueID()) === false) {
  17. self::markTestSkipped('memcached server seems to be down.');
  18. }
  19. }
  20. protected function setUp() {
  21. parent::setUp();
  22. $this->instance = new \OC\Memcache\Memcached($this->getUniqueID());
  23. }
  24. public function testClear() {
  25. // Memcached is sometimes broken with clear(), so we don't test it thoroughly
  26. $value='ipsum lorum';
  27. $this->instance->set('1_value1', $value);
  28. $this->instance->set('1_value2', $value);
  29. $this->instance->set('2_value1', $value);
  30. $this->instance->set('3_value1', $value);
  31. $this->assertTrue($this->instance->clear('1_'));
  32. $this->assertFalse($this->instance->hasKey('1_value1'));
  33. $this->assertFalse($this->instance->hasKey('1_value2'));
  34. //$this->assertTrue($this->instance->hasKey('2_value1'));
  35. //$this->assertTrue($this->instance->hasKey('3_value1'));
  36. $this->assertTrue($this->instance->clear());
  37. $this->assertFalse($this->instance->hasKey('1_value1'));
  38. $this->assertFalse($this->instance->hasKey('1_value2'));
  39. $this->assertFalse($this->instance->hasKey('2_value1'));
  40. $this->assertFalse($this->instance->hasKey('3_value1'));
  41. }
  42. }