diff --git a/tests/Predis/Command/KeyExpireAtTest.php b/tests/Predis/Command/KeyExpireAtTest.php index 354174a2..ec3dbf64 100644 --- a/tests/Predis/Command/KeyExpireAtTest.php +++ b/tests/Predis/Command/KeyExpireAtTest.php @@ -78,13 +78,14 @@ class KeyExpireAtTest extends PredisCommandTestCase $redis = $this->getClient(); $now = time(); - $redis->set('foo', 'bar'); + $this->assertEquals('OK', $redis->set('foo', 'bar')); $this->assertSame(1, $redis->expireat('foo', $now + 1)); - $this->assertLessThanOrEqual(1, $redis->ttl('foo')); - - $this->sleep(2); + $this->assertThat($redis->ttl('foo'), $this->logicalAnd( + $this->greaterThanOrEqual(0), $this->lessThanOrEqual(1) + )); + $this->sleep(2.0); $this->assertSame(0, $redis->exists('foo')); } @@ -96,7 +97,7 @@ class KeyExpireAtTest extends PredisCommandTestCase $redis = $this->getClient(); $now = time(); - $redis->set('foo', 'bar'); + $this->assertEquals('OK', $redis->set('foo', 'bar')); $this->assertSame(1, $redis->expireat('foo', $now - 100)); $this->assertSame(0, $redis->exists('foo')); diff --git a/tests/Predis/Command/KeyExpireTest.php b/tests/Predis/Command/KeyExpireTest.php index 461170cf..1c0563f9 100644 --- a/tests/Predis/Command/KeyExpireTest.php +++ b/tests/Predis/Command/KeyExpireTest.php @@ -77,32 +77,15 @@ class KeyExpireTest extends PredisCommandTestCase { $redis = $this->getClient(); - $redis->set('foo', 'bar'); + $this->assertEquals('OK', $redis->set('foo', 'bar')); $this->assertSame(1, $redis->expire('foo', 1)); $this->assertSame(1, $redis->ttl('foo')); $this->sleep(2.0); - $this->assertSame(0, $redis->exists('foo')); } - /** - * @medium - * @group connected - * @group slow - */ - public function testConsistencyWithTTL() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertSame(1, $redis->expire('foo', 10)); - $this->sleep(1.5); - $this->assertLessThan(10, $redis->ttl('foo')); - } - /** * @group connected */ @@ -110,7 +93,7 @@ class KeyExpireTest extends PredisCommandTestCase { $redis = $this->getClient(); - $redis->set('foo', 'bar'); + $this->assertEquals('OK', $redis->set('foo', 'bar')); $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 2f603d7c..201e088e 100644 --- a/tests/Predis/Command/KeyPreciseExpireTest.php +++ b/tests/Predis/Command/KeyPreciseExpireTest.php @@ -75,11 +75,10 @@ class KeyPreciseExpireTest extends PredisCommandTestCase */ public function testCanExpireKeys() { - $ttl = 1 * 1000; + $ttl = 1000; $redis = $this->getClient(); - $redis->set('foo', 'bar'); - + $this->assertEquals('OK', $redis->set('foo', 'bar')); $this->assertSame(1, $redis->pexpire('foo', $ttl)); $this->sleep(1.2); @@ -87,21 +86,22 @@ class KeyPreciseExpireTest extends PredisCommandTestCase } /** + * @medium * @group connected * @group slow */ - public function testConsistencyWithTTL() - { - $ttl = 1 * 1000; + public function testConsistencyWithTTL() + { + $ttl = 1000; $redis = $this->getClient(); - $redis->set('foo', 'bar'); - + $this->assertEquals('OK', $redis->set('foo', 'bar')); $this->assertSame(1, $redis->pexpire('foo', $ttl)); $this->sleep(0.5); - $this->assertLessThanOrEqual($ttl, $redis->pttl('foo')); - $this->assertGreaterThan($ttl - 800, $redis->pttl('foo')); + $this->assertThat($redis->pttl('foo'), $this->logicalAnd( + $this->lessThanOrEqual($ttl), $this->greaterThan($ttl - 800) + )); } /** @@ -111,7 +111,7 @@ class KeyPreciseExpireTest extends PredisCommandTestCase { $redis = $this->getClient(); - $redis->set('foo', 'bar'); + $this->assertEquals('OK', $redis->set('foo', 'bar')); $this->assertSame(1, $redis->pexpire('foo', -10000)); $this->assertSame(0, $redis->exists('foo')); diff --git a/tests/Predis/Command/StringPreciseSetExpireTest.php b/tests/Predis/Command/StringPreciseSetExpireTest.php index efa4b18e..d09df63b 100644 --- a/tests/Predis/Command/StringPreciseSetExpireTest.php +++ b/tests/Predis/Command/StringPreciseSetExpireTest.php @@ -64,7 +64,7 @@ class StringPreciseSetExpireTest extends PredisCommandTestCase $this->assertEquals('OK', $redis->psetex('foo', 10000, 'bar')); $this->assertSame(1, $redis->exists('foo')); - $this->assertEquals(10, $redis->ttl('foo')); + $this->assertSame(10, $redis->ttl('foo')); } /** @@ -75,7 +75,8 @@ class StringPreciseSetExpireTest extends PredisCommandTestCase { $redis = $this->getClient(); - $redis->psetex('foo', 50, 'bar'); + $this->assertEquals('OK', $redis->psetex('foo', 50, 'bar')); + $this->sleep(0.5); $this->assertSame(0, $redis->exists('foo')); } diff --git a/tests/Predis/Command/StringSetExpireTest.php b/tests/Predis/Command/StringSetExpireTest.php index 7a7f1d15..f69226ba 100644 --- a/tests/Predis/Command/StringSetExpireTest.php +++ b/tests/Predis/Command/StringSetExpireTest.php @@ -64,7 +64,7 @@ class StringSetExpireTest extends PredisCommandTestCase $this->assertEquals('OK', $redis->setex('foo', 10, 'bar')); $this->assertSame(1, $redis->exists('foo')); - $this->assertEquals(10, $redis->ttl('foo')); + $this->assertSame(10, $redis->ttl('foo')); } /** @@ -76,7 +76,8 @@ class StringSetExpireTest extends PredisCommandTestCase { $redis = $this->getClient(); - $redis->setex('foo', 1, 'bar'); + $this->assertEquals('OK', $redis->setex('foo', 1, 'bar')); + $this->sleep(2.0); $this->assertSame(0, $redis->exists('foo')); }