From 082c51146a573ec976f99f81559854e11cd05ac8 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Fri, 24 Jul 2015 15:34:01 +0200 Subject: [PATCH] Do not parse response to EXPIREAT into boolean value. --- src/Command/KeyExpireAt.php | 8 -------- tests/Predis/Command/KeyExpireAtTest.php | 10 +++++----- tests/Predis/Command/KeyPreciseExpireAtTest.php | 8 ++++---- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/Command/KeyExpireAt.php b/src/Command/KeyExpireAt.php index 6d8cc4c1..8d7b87c0 100644 --- a/src/Command/KeyExpireAt.php +++ b/src/Command/KeyExpireAt.php @@ -24,12 +24,4 @@ class KeyExpireAt extends Command { return 'EXPIREAT'; } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } } diff --git a/tests/Predis/Command/KeyExpireAtTest.php b/tests/Predis/Command/KeyExpireAtTest.php index 1567d7d8..354174a2 100644 --- a/tests/Predis/Command/KeyExpireAtTest.php +++ b/tests/Predis/Command/KeyExpireAtTest.php @@ -54,8 +54,8 @@ class KeyExpireAtTest extends PredisCommandTestCase { $command = $this->getCommand(); - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); + $this->assertSame(0, $command->parseResponse(0)); + $this->assertSame(1, $command->parseResponse(1)); } /** @@ -65,7 +65,7 @@ class KeyExpireAtTest extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertFalse($redis->expireat('foo', 2)); + $this->assertSame(0, $redis->expireat('foo', 2)); } /** @@ -80,7 +80,7 @@ class KeyExpireAtTest extends PredisCommandTestCase $now = time(); $redis->set('foo', 'bar'); - $this->assertTrue($redis->expireat('foo', $now + 1)); + $this->assertSame(1, $redis->expireat('foo', $now + 1)); $this->assertLessThanOrEqual(1, $redis->ttl('foo')); $this->sleep(2); @@ -98,7 +98,7 @@ class KeyExpireAtTest extends PredisCommandTestCase $now = time(); $redis->set('foo', 'bar'); - $this->assertTrue($redis->expireat('foo', $now - 100)); + $this->assertSame(1, $redis->expireat('foo', $now - 100)); $this->assertSame(0, $redis->exists('foo')); } } diff --git a/tests/Predis/Command/KeyPreciseExpireAtTest.php b/tests/Predis/Command/KeyPreciseExpireAtTest.php index c2cb825b..edf0ea1c 100644 --- a/tests/Predis/Command/KeyPreciseExpireAtTest.php +++ b/tests/Predis/Command/KeyPreciseExpireAtTest.php @@ -54,8 +54,8 @@ class KeyPreciseExpireAtTest extends PredisCommandTestCase { $command = $this->getCommand(); - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); + $this->assertSame(0, $command->parseResponse(0)); + $this->assertSame(1, $command->parseResponse(1)); } /** @@ -70,7 +70,7 @@ class KeyPreciseExpireAtTest extends PredisCommandTestCase $redis->set('foo', 'bar'); - $this->assertTrue($redis->pexpireat('foo', time() + $ttl * 1000)); + $this->assertSame(1, $redis->pexpireat('foo', time() + $ttl * 1000)); $this->assertLessThan($ttl * 1000, $redis->pttl('foo')); $this->sleep($ttl + 0.5); @@ -87,7 +87,7 @@ class KeyPreciseExpireAtTest extends PredisCommandTestCase $redis->set('foo', 'bar'); - $this->assertTrue($redis->expireat('foo', time() - 100000)); + $this->assertSame(1, $redis->expireat('foo', time() - 100000)); $this->assertSame(0, $redis->exists('foo')); } }