コード例 #1
0
 /**
  * Test 'increment' method.
  */
 public function testIncrement()
 {
     $testKey = 'abc123';
     $testValue = 1;
     $mock = new MemcachedMock();
     $this->assertFalse($mock->increment('a'));
     $mock = $this->getMemcachedMock();
     $mock->setThrowExceptionsOnFailure(false);
     $this->assertFalse($mock->increment(null));
     $this->assertFalse($mock->increment('string', 1, 1, 'abc'));
     $mock->setThrowExceptionsOnFailure(true);
     $this->assertTrue($mock->set($testKey, $testValue));
     $this->assertSame($testValue + 1, $mock->increment($testKey, 1));
     $this->assertSame($testValue + 1, $mock->get($testKey));
     $testKey = 'abc124';
     $testValue = 44;
     $expiry = 8;
     $expiryReal = time() + $expiry;
     $this->assertSame($testValue, $mock->increment($testKey, 5, $testValue, $expiry));
     $this->assertSame($testValue, $mock->get($testKey));
     $this->assertSame($expiryReal, $mock->getExpiry($testKey));
     $mock->setThrowExceptionsOnFailure(false);
     $this->assertFalse($mock->increment($testKey, 'invalid', $testValue, $expiry));
     $mock->set($testKey, 'test');
     $this->assertFalse($mock->increment($testKey, 1));
 }