diff --git a/.travis.yml b/.travis.yml index 54b07b8..74752d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: php php: + - 5.3 - 5.4 before_script: diff --git a/README.md b/README.md index 71091de..c0c27d7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Redis PHP Mock [![Build Status](https://secure.travis-ci.org/M6Web/RedisMock.png)](http://travis-ci.org/M6Web/RedisMock) -PHP 5.4+ library providing a Redis PHP mock for your tests. +PHP 5.3 library providing a Redis PHP mock for your tests. ## Installation @@ -9,7 +9,7 @@ Add this line in your `composer.json` : ```json { "require": { - "m6web/redis-mock": "dev-master" + "m6web/redis-mock": "~1.2" } } ``` diff --git a/composer.json b/composer.json index 7780ad8..39e1e00 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "psr-0": {"M6Web\\Component\\RedisMock": "src/"} }, "require": { - "php": ">=5.4.0" + "php": ">=5.3.0" }, "require-dev": { "atoum/atoum": "master-dev" diff --git a/src/M6Web/Component/RedisMock/RedisMock.php b/src/M6Web/Component/RedisMock/RedisMock.php index a804e31..bc1aeb8 100644 --- a/src/M6Web/Component/RedisMock/RedisMock.php +++ b/src/M6Web/Component/RedisMock/RedisMock.php @@ -248,7 +248,7 @@ public function zrevrange($key, $start, $stop, $withscores = false) return self::$pipeline ? $this : array_slice($set, $start, $length); } - public function zrangebyscore($key, $min, $max, array $options = []) + public function zrangebyscore($key, $min, $max, array $options = array()) { if (!empty($options['withscores'])) { throw new UnsupportedException('Parameter `withscores` is not supported by RedisMock for `zrangebyscore` command.'); @@ -309,7 +309,7 @@ public function zrangebyscore($key, $min, $max, array $options = []) return self::$pipeline ? $this : array_values(array_slice($results, $options['limit'][0], $options['limit'][1], true)); } - public function zrevrangebyscore($key, $max, $min, array $options = []) + public function zrevrangebyscore($key, $max, $min, array $options = array()) { if (!empty($options['withscores'])) { throw new UnsupportedException('Parameter `withscores` is not supported by RedisMock for `zrevrangebyscore` command.'); @@ -354,7 +354,7 @@ public function zrevrangebyscore($key, $max, $min, array $options = []) } }; - $results = []; + $results = array(); foreach (self::$data[$key] as $k => $v) { if ($min == '-inf' && $isInfMax($v)) { $results[] = $k; diff --git a/tests/units/RedisMock.php b/tests/units/RedisMock.php index e31feae..f909e85 100644 --- a/tests/units/RedisMock.php +++ b/tests/units/RedisMock.php @@ -82,22 +82,22 @@ public function testKeys() { ->isEmpty() ->array($redisMock->keys('some*')) ->hasSize(2) - ->containsValues(['something', 'someting_else']) + ->containsValues(array('something', 'someting_else')) ->array($redisMock->keys('*o*')) ->hasSize(3) - ->containsValues(['something', 'someting_else', 'others']) + ->containsValues(array('something', 'someting_else', 'others')) ->array($redisMock->keys('*[ra]s*')) ->hasSize(1) - ->containsValues(['others']) + ->containsValues(array('others')) ->array($redisMock->keys('*[rl]s*')) ->hasSize(2) - ->containsValues(['someting_else', 'others']) + ->containsValues(array('someting_else', 'others')) ->array($redisMock->keys('somet?ing*')) ->hasSize(1) - ->containsValues(['something']) + ->containsValues(array('something')) ->array($redisMock->keys('somet*ing*')) ->hasSize(2) - ->containsValues(['something', 'someting_else']); + ->containsValues(array('something', 'someting_else')); } public function testSAddSMembersSIsMemberSRem() @@ -129,7 +129,7 @@ public function testSAddSMembersSIsMemberSRem() ->isEqualTo(0) ->array($redisMock->smembers('test')) ->hasSize(1) - ->containsValues(['test1']) + ->containsValues(array('test1')) ->integer($redisMock->srem('test', 'test1')) ->isEqualTo(1) ->integer($redisMock->sismember('test', 'test1')) @@ -140,7 +140,7 @@ public function testSAddSMembersSIsMemberSRem() ->isEqualTo(1) ->array($redisMock->smembers('test')) ->hasSize(2) - ->containsValues(['test1', 'test2']) + ->containsValues(array('test1', 'test2')) ->exception(function() use ($redisMock) { $redisMock->srem('test', 'test1', 'test2'); }) @@ -387,24 +387,24 @@ public function testZRangeByScore() 'test3', 'test2', )) - ->array($redisMock->zrangebyscore('test', '-inf', '15', ['limit' => [0, 2]])) + ->array($redisMock->zrangebyscore('test', '-inf', '15', array('limit' => array(0, 2)))) ->isEqualTo(array( 'test6', 'test1', )) - ->array($redisMock->zrangebyscore('test', '-inf', '15', ['limit' => [1, 2]])) + ->array($redisMock->zrangebyscore('test', '-inf', '15', array('limit' => array(1, 2)))) ->isEqualTo(array( 'test1', 'test4', )) - ->array($redisMock->zrangebyscore('test', '-inf', '15', ['limit' => [1, 3]])) + ->array($redisMock->zrangebyscore('test', '-inf', '15', array('limit' => array(1, 3)))) ->isEqualTo(array( 'test1', 'test4', 'test3', )) ->exception(function() use ($redisMock) { - $redisMock->zrangebyscore('test', '-inf', '15', ['limit' => [1, 3], 'withscores' => true]); + $redisMock->zrangebyscore('test', '-inf', '15', array('limit' => array(1, 3), 'withscores' => true)); }) ->isInstanceOf('\M6Web\Component\RedisMock\UnsupportedException') ->integer($redisMock->del('test')) @@ -468,24 +468,24 @@ public function testZRevRangeByScore() 'test2', 'test3', )) - ->array($redisMock->zrevrangebyscore('test', '15', '-inf', ['limit' => [0, 2]])) + ->array($redisMock->zrevrangebyscore('test', '15', '-inf', array('limit' => array(0, 2)))) ->isEqualTo(array( 'test2', 'test3', )) - ->array($redisMock->zrevrangebyscore('test', '15', '-inf', ['limit' => [1, 2]])) + ->array($redisMock->zrevrangebyscore('test', '15', '-inf', array('limit' => array(1, 2)))) ->isEqualTo(array( 'test3', 'test4', )) - ->array($redisMock->zrevrangebyscore('test', '15', '-inf', ['limit' => [1, 3]])) + ->array($redisMock->zrevrangebyscore('test', '15', '-inf', array('limit' => array(1, 3)))) ->isEqualTo(array( 'test3', 'test4', 'test1', )) ->exception(function() use ($redisMock) { - $redisMock->zrevrangebyscore('test', '15', '-inf', ['limit' => [1, 3], 'withscores' => true]); + $redisMock->zrevrangebyscore('test', '15', '-inf', array('limit' => array(1, 3), 'withscores' => true)); }) ->isInstanceOf('\M6Web\Component\RedisMock\UnsupportedException') ->integer($redisMock->del('test')) @@ -519,12 +519,12 @@ public function testHSetHGetHexistsHGetAll() ->isEqualTo('something else') ->array($redisMock->hgetall('test')) ->hasSize(1) - ->containsValues(['something else']) + ->containsValues(array('something else')) ->integer($redisMock->hset('test', 'test2', 'something')) ->isEqualTo(1) ->array($redisMock->hgetall('test')) ->hasSize(2) - ->containsValues(['something', 'something else']) + ->containsValues(array('something', 'something else')) ->integer($redisMock->hexists('test', 'test1')) ->isEqualTo(1) ->integer($redisMock->hexists('test', 'test3')) diff --git a/tests/units/RedisMockFactory.php b/tests/units/RedisMockFactory.php index dc4927d..7634039 100644 --- a/tests/units/RedisMockFactory.php +++ b/tests/units/RedisMockFactory.php @@ -37,7 +37,7 @@ public function testMock() ->integer($mock->sAdd('test', 'test2')) ->isEqualTo(1) ->array($mock->sMembers('test')) - ->isEqualTo(['test1', 'test2']) + ->isEqualTo(array('test1', 'test2')) ->integer($mock->sRem('test', 'test1')) ->isEqualTo(1) ->integer($mock->sRem('test', 'test2')) @@ -91,12 +91,12 @@ public function testMockComplex() 'test3', 'test2' )) - ->array($mock->zRangeByScore('test', '-inf', '+inf', ['limit' => [1, 2]])) + ->array($mock->zRangeByScore('test', '-inf', '+inf', array('limit' => array(1, 2)))) ->isEqualTo(array( 'test3', 'test2' )) - ->array($mock->zrevrangebyscore('test', '+inf', '-inf', ['limit' => [1, 2]])) + ->array($mock->zrevrangebyscore('test', '+inf', '-inf', array('limit' => array(1, 2)))) ->isEqualTo(array( 'test3', 'test1'