From b02e3f491129611de1dc9cfd233bed57cb13e021 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Fri, 24 Jul 2015 15:32:15 +0200 Subject: [PATCH] Do not parse response to EXPIRE into boolean value. --- src/Command/KeyExpire.php | 8 -------- tests/Predis/Command/KeyExpireTest.php | 12 ++++++------ tests/Predis/Command/KeyPreciseExpireTest.php | 12 ++++++------ 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/Command/KeyExpire.php b/src/Command/KeyExpire.php index 8ad9715a..da384363 100644 --- a/src/Command/KeyExpire.php +++ b/src/Command/KeyExpire.php @@ -24,12 +24,4 @@ class KeyExpire extends Command { return 'EXPIRE'; } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } } diff --git a/tests/Predis/Command/KeyExpireTest.php b/tests/Predis/Command/KeyExpireTest.php index a27060eb..461170cf 100644 --- a/tests/Predis/Command/KeyExpireTest.php +++ b/tests/Predis/Command/KeyExpireTest.php @@ -54,8 +54,8 @@ class KeyExpireTest 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 KeyExpireTest extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertFalse($redis->expire('foo', 2)); + $this->assertSame(0, $redis->expire('foo', 2)); } /** @@ -79,7 +79,7 @@ class KeyExpireTest extends PredisCommandTestCase $redis->set('foo', 'bar'); - $this->assertTrue($redis->expire('foo', 1)); + $this->assertSame(1, $redis->expire('foo', 1)); $this->assertSame(1, $redis->ttl('foo')); $this->sleep(2.0); @@ -98,7 +98,7 @@ class KeyExpireTest extends PredisCommandTestCase $redis->set('foo', 'bar'); - $this->assertTrue($redis->expire('foo', 10)); + $this->assertSame(1, $redis->expire('foo', 10)); $this->sleep(1.5); $this->assertLessThan(10, $redis->ttl('foo')); } @@ -112,7 +112,7 @@ class KeyExpireTest extends PredisCommandTestCase $redis->set('foo', 'bar'); - $this->assertTrue($redis->expire('foo', -10)); + $this->assertSame(1, $redis->expire('foo', -10)); $this->assertSame(0, $redis->exists('foo')); } } diff --git a/tests/Predis/Command/KeyPreciseExpireTest.php b/tests/Predis/Command/KeyPreciseExpireTest.php index c0173949..2f603d7c 100644 --- a/tests/Predis/Command/KeyPreciseExpireTest.php +++ b/tests/Predis/Command/KeyPreciseExpireTest.php @@ -54,8 +54,8 @@ class KeyPreciseExpireTest 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 KeyPreciseExpireTest extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertFalse($redis->pexpire('foo', 20000)); + $this->assertSame(0, $redis->pexpire('foo', 20000)); } /** @@ -80,7 +80,7 @@ class KeyPreciseExpireTest extends PredisCommandTestCase $redis->set('foo', 'bar'); - $this->assertTrue($redis->pexpire('foo', $ttl)); + $this->assertSame(1, $redis->pexpire('foo', $ttl)); $this->sleep(1.2); $this->assertSame(0, $redis->exists('foo')); @@ -97,7 +97,7 @@ class KeyPreciseExpireTest extends PredisCommandTestCase $redis->set('foo', 'bar'); - $this->assertTrue($redis->pexpire('foo', $ttl)); + $this->assertSame(1, $redis->pexpire('foo', $ttl)); $this->sleep(0.5); $this->assertLessThanOrEqual($ttl, $redis->pttl('foo')); @@ -113,7 +113,7 @@ class KeyPreciseExpireTest extends PredisCommandTestCase $redis->set('foo', 'bar'); - $this->assertTrue($redis->pexpire('foo', -10000)); + $this->assertSame(1, $redis->pexpire('foo', -10000)); $this->assertSame(0, $redis->exists('foo')); } }