diff --git a/src/M6Web/Component/RedisMock/RedisMock.php b/src/M6Web/Component/RedisMock/RedisMock.php index 5b4597c..b5261af 100644 --- a/src/M6Web/Component/RedisMock/RedisMock.php +++ b/src/M6Web/Component/RedisMock/RedisMock.php @@ -910,7 +910,7 @@ protected function zrangebyscoreHelper($key, $min, $max, array $options = array( if ($min == '-inf' && $max == '+inf') { $slice = array_slice(self::$dataValues[$this->storage][$key], $options['limit'][0], $options['limit'][1], true); if (isset($options['withscores']) && $options['withscores']) { - return $this->returnPipedInfo($slice); + return $this->returnPipedInfo(array_map('strval', $slice)); } else { return $this->returnPipedInfo(array_keys($slice)); } @@ -947,14 +947,12 @@ protected function zrangebyscoreHelper($key, $min, $max, array $options = array( $slice = array_slice($results, $options['limit'][0], $options['limit'][1], true); if (isset($options['withscores']) && $options['withscores']) { - return $this->returnPipedInfo($slice); + return $this->returnPipedInfo(array_map('strval', $slice)); } else { return $this->returnPipedInfo(array_keys($slice)); } } - - public function zrangebyscore($key, $min, $max, array $options = array()) { return $this->zrangebyscoreHelper($key, $min, $max, $options, false); @@ -965,7 +963,6 @@ public function zrevrangebyscore($key, $max, $min, array $options = array()) return $this->zrangebyscoreHelper($key, $min, $max, $options, true); } - public function zadd($key, ...$args) { if (count($args) === 1) { if (count($args[0]) > 1) { @@ -1010,7 +1007,7 @@ public function zscore($key, $member) return $this->returnPipedInfo(null); } - return $this->returnPipedInfo(self::$dataValues[$this->storage][$key][$member]); + return $this->returnPipedInfo((string) self::$dataValues[$this->storage][$key][$member]); } public function zcard($key) diff --git a/tests/units/RedisMock.php b/tests/units/RedisMock.php index 4726bb6..8b6b17c 100644 --- a/tests/units/RedisMock.php +++ b/tests/units/RedisMock.php @@ -717,11 +717,11 @@ public function testZScore() $redisMock->zadd('test', 15, 'test2'); $this->assert - ->integer($redisMock->zscore('test', 'test4')) + ->string($redisMock->zscore('test', 'test4')) ->isEqualTo(1); $this->assert - ->integer($redisMock->zscore('test', 'test2')) + ->string($redisMock->zscore('test', 'test2')) ->isEqualTo(15); $this->assert @@ -960,10 +960,10 @@ public function testZRevRange() 'test6', )) ->array($redisMock->zrevrange('test', 1, -3, true)) - ->isEqualTo(array( - 'test2' => 15, - 'test3' => 2, - 'test4' => 1, + ->isIdenticalTo(array( + 'test2' => '15', + 'test3' => '2', + 'test4' => '1', )) ->integer($redisMock->del('test')) ->isEqualTo(6) @@ -1058,10 +1058,10 @@ public function testZRangeByScore() 'test3', )) ->array($redisMock->zrangebyscore('test', '-inf', '15', array('limit' => array(1, 3), 'withscores' => true))) - ->isEqualTo(array( - 'test1' => 1, - 'test4' => 1, - 'test3' => 2, + ->isIdenticalTo(array( + 'test1' => '1', + 'test4' => '1', + 'test3' => '2', )) ->integer($redisMock->del('test')) ->isEqualTo(6) @@ -1155,10 +1155,10 @@ public function testZRevRangeByScore() 'test1', )) ->array($redisMock->zrevrangebyscore('test', '15', '-inf', array('limit' => array(1, 3), 'withscores' => true))) - ->isEqualTo(array( - 'test3' => 2, - 'test4' => 1, - 'test1' => 1, + ->isIdenticalTo(array( + 'test3' => '2', + 'test4' => '1', + 'test1' => '1', )) ->integer($redisMock->del('test')) ->isEqualTo(6) @@ -1171,7 +1171,7 @@ public function testZRevRangeByScore() sleep(2); $this->assert ->array($redisMock->zrevrangebyscore('test', '1', '0')) - ->isEmpty();; + ->isEmpty(); } public function testHSetHMSetHGetHDelHExistsHKeysHLenHGetAll()