1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- namespace Predis\Command;
- class KeyPreciseExpireAtTest extends PredisCommandTestCase
- {
-
- protected function getExpectedCommand()
- {
- return 'Predis\Command\KeyPreciseExpireAt';
- }
-
- protected function getExpectedId()
- {
- return 'PEXPIREAT';
- }
-
- public function testFilterArguments()
- {
- $arguments = array('key', 100);
- $expected = array('key', 100);
- $command = $this->getCommand();
- $command->setArguments($arguments);
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testParseResponse()
- {
- $command = $this->getCommand();
- $this->assertTrue($command->parseResponse(1));
- $this->assertFalse($command->parseResponse(0));
- }
-
- public function testCanExpireKeys()
- {
- $ttl = 1.5;
- $redis = $this->getClient();
- $this->assertEquals('OK', $redis->set('foo', 'bar'));
- $this->assertTrue($redis->pexpireat('foo', time() + $ttl * 1000));
- $this->assertLessThan($ttl * 1000, $redis->pttl('foo'));
- $this->sleep($ttl + 0.5);
- $this->assertFalse($redis->exists('foo'));
- }
-
- public function testDeletesKeysOnPastUnixTime()
- {
- $redis = $this->getClient();
- $this->assertEquals('OK', $redis->set('foo', 'bar'));
- $this->assertTrue($redis->expireat('foo', time() - 100000));
- $this->assertFalse($redis->exists('foo'));
- }
- }
|