/** * Test 'decrement' method. */ public function testDecrement() { $mock = new MemcachedMock(); $this->assertFalse($mock->decrement('a')); $testKey = 'abc456'; $testValue = 10; $mock = $this->getMemcachedMock(); $mock->setThrowExceptionsOnFailure(false); $this->assertFalse($mock->decrement(false)); $this->assertFalse($mock->decrement('a', 1, 1, 'invalid')); $this->assertFalse($mock->decrement('a', 1, 'invalid')); $this->assertSame(2, $mock->decrement('a', 1, 2)); $mock->setThrowExceptionsOnFailure(true); $this->assertTrue($mock->set($testKey, $testValue)); $this->assertSame($testValue - 2, $mock->decrement($testKey, 2)); $this->assertSame($testValue - 2, $mock->get($testKey)); $testKey = 'abc789'; $testValue = 55; $expiry = 20; $expiryReal = time() + $expiry; $this->assertSame($testValue, $mock->decrement($testKey, 7, $testValue, $expiry)); $this->assertSame($testValue, $mock->get($testKey)); $this->assertSame($expiryReal, $mock->getExpiry($testKey)); $this->assertTrue($mock->set($testKey, 1)); $this->assertSame(0, $mock->decrement($testKey, 2)); $this->assertSame(0, $mock->get($testKey)); $mock->setThrowExceptionsOnFailure(false); $this->assertSame(0, $mock->get($testKey)); $this->assertFalse($mock->decrement($testKey, 'invalid', $testValue, $expiry)); $mock->set($testKey, 'test'); $this->assertFalse($mock->decrement($testKey, 1)); }