コード例 #1
0
 public function testAssertHasNotInDeleteQueue()
 {
     $mock = new MemcachedMock();
     $mock->setThrowExceptionsOnFailure(true);
     $mock->addServer('127.0.0.1', 11211);
     $mock->set('a', 'b');
     $mock->delete('a', 100);
     $mock->setThrowExceptionsOnFailure(false);
     $mockReflection = new \ReflectionClass($mock);
     $method = $mockReflection->getMethod('assertHasNotInDeleteQueue');
     $method->setAccessible(true);
     $this->assertFalse($method->invokeArgs($mock, ['a']));
 }
コード例 #2
0
 public function testDelayedDelete()
 {
     $mock = new MemcachedMock();
     $this->assertFalse($mock->delete('123'));
     $testKey = 'delete789';
     $testValue = 55;
     $mock = $this->getMemcachedMock();
     $mockReflection = new \ReflectionClass($mock);
     $method = $mockReflection->getMethod('assertHasNotInDeleteQueue');
     $method->setAccessible(true);
     $mock->setThrowExceptionsOnFailure(false);
     $this->assertFalse($mock->delete(null));
     // invalid key
     $this->assertFalse($mock->delete($testKey));
     // not in cache
     $this->assertTrue($mock->set($testKey, $testValue));
     $this->assertFalse($mock->delete($testKey, false));
     // invalid time
     $this->assertTrue($mock->delete($testKey, 1));
     // set delay delete queue EOL to 1 second
     $this->assertTrue($mock->delete($testKey, 50));
     // try to set to 50, is OK but does not effect EOL of 1 second
     $this->assertFalse($mock->add($testKey, $testValue));
     // not allowed while key is in delete queue
     $this->assertFalse($mock->replace($testKey, $testValue));
     // not allowed while key is in delete queue
     $this->assertTrue($mock->set($testKey, $testValue));
     // allowed while in key is in delete queue
     $this->assertFalse($mock->get($testKey));
     // key is in delete queue
     sleep(2);
     $this->assertTrue($mock->add($testKey, $testValue));
 }