Skip to content

Commit

Permalink
Merge pull request #90 from alex-scott/patch-1
Browse files Browse the repository at this point in the history
lrem() function - parameters order fixed
  • Loading branch information
Oliboy50 authored Jan 8, 2020
2 parents 057ad8e + d20232c commit 1b7a1bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/M6Web/Component/RedisMock/RedisMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ public function lindex($key, $index)
return $this->returnPipedInfo(self::$dataValues[$this->storage][$key][$position]);
}

public function lrem($key, $count, $value)
public function lrem($key, $value, $count)
{
if (!isset(self::$dataValues[$this->storage][$key]) || !in_array($value, self::$dataValues[$this->storage][$key]) || $this->deleteOnTtlExpired($key)) {
return $this->returnPipedInfo(0);
Expand Down
14 changes: 7 additions & 7 deletions tests/units/RedisMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -1497,11 +1497,11 @@ public function testLPushRPushLRemLTrim()
->isIdenticalTo(4)
->array($redisMock->getData())
->isEqualTo(array('test' => array('raoul', 'blabla', 'something', 'raoul')))
->integer($redisMock->lrem('test', 2, 'blabla'))
->integer($redisMock->lrem('test', 'blabla', 2))
->isIdenticalTo(1)
->array($redisMock->getData())
->isEqualTo(array('test' => array('raoul', 'something', 'raoul')))
->integer($redisMock->lrem('test', 1, 'raoul'))
->integer($redisMock->lrem('test', 'raoul', 1))
->isIdenticalTo(1)
->array($redisMock->getData())
->isEqualTo(array('test' => array('something', 'raoul')))
Expand All @@ -1513,7 +1513,7 @@ public function testLPushRPushLRemLTrim()
->isIdenticalTo(5)
->array($redisMock->getData())
->isEqualTo(array('test' => array('raoul', 'something', 'raoul', 'raoul', 'raoul')))
->integer($redisMock->lrem('test', -2, 'raoul'))
->integer($redisMock->lrem('test', 'raoul', -2))
->isIdenticalTo(2)
->array($redisMock->getData())
->isEqualTo(array('test' => array('raoul', 'something', 'raoul')))
Expand All @@ -1523,7 +1523,7 @@ public function testLPushRPushLRemLTrim()
->isIdenticalTo(5)
->array($redisMock->getData())
->isEqualTo(array('test' => array('raoul', 'something', 'raoul', 'raoul', 'raoul')))
->integer($redisMock->lrem('test', 0, 'raoul'))
->integer($redisMock->lrem('test', 'raoul', 0))
->isIdenticalTo(4)
->array($redisMock->getData())
->isEqualTo(array('test' => array('something')))
Expand Down Expand Up @@ -1597,13 +1597,13 @@ public function testLPushRPushLRemLTrim()
->isEqualTo(1)
->integer($redisMock->rpush('test', 'test1'))
->isEqualTo(2)
->integer($redisMock->lrem('test', 1 , 'test1'))
->integer($redisMock->lrem('test', 'test1', 1))
->isEqualTo(1)
->integer($redisMock->expire('test', 1))
->isEqualTo(1);
sleep(2);
$this->assert
->integer($redisMock->lrem('test', 1 , 'test1'))
->integer($redisMock->lrem('test', 'test1', 1))
->isEqualTo(0);

$this->assert
Expand Down Expand Up @@ -1667,7 +1667,7 @@ public function testPipeline()
->lpush('test', 'test1')
->lrange('test', 0, -1)
->ltrim('test', 0, -1)
->lrem('test', 1, 'test1')
->lrem('test', 'test1', 1)
->rpush('test', 'test1')
->type('test')
->ttl('test')
Expand Down

0 comments on commit 1b7a1bc

Please sign in to comment.