cache.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. abstract class Cache extends \Test_Cache {
  10. public function testExistsAfterSet() {
  11. $this->assertFalse($this->instance->hasKey('foo'));
  12. $this->instance->set('foo', 'bar');
  13. $this->assertTrue($this->instance->hasKey('foo'));
  14. }
  15. public function testGetAfterSet() {
  16. $this->assertNull($this->instance->get('foo'));
  17. $this->instance->set('foo', 'bar');
  18. $this->assertEquals('bar', $this->instance->get('foo'));
  19. }
  20. public function testDoesNotExistAfterRemove() {
  21. $this->instance->set('foo', 'bar');
  22. $this->instance->remove('foo');
  23. $this->assertFalse($this->instance->hasKey('foo'));
  24. }
  25. public function testArrayAccessSet() {
  26. $this->instance['foo'] = 'bar';
  27. $this->assertEquals('bar', $this->instance->get('foo'));
  28. }
  29. public function testArrayAccessGet() {
  30. $this->instance->set('foo', 'bar');
  31. $this->assertEquals('bar', $this->instance['foo']);
  32. }
  33. public function testArrayAccessExists() {
  34. $this->assertFalse(isset($this->instance['foo']));
  35. $this->instance->set('foo', 'bar');
  36. $this->assertTrue(isset($this->instance['foo']));
  37. }
  38. public function testArrayAccessUnset() {
  39. $this->instance->set('foo', 'bar');
  40. unset($this->instance['foo']);
  41. $this->assertFalse($this->instance->hasKey('foo'));
  42. }
  43. public function tearDown() {
  44. if ($this->instance) {
  45. $this->instance->clear();
  46. }
  47. }
  48. }