Skip to content

Commit

Permalink
More unit tests to cover ranges and redis transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
ziogas committed Apr 20, 2017
1 parent 016a8a6 commit cfe4360
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/commands.php
Expand Up @@ -65,13 +65,49 @@ public function testSets() {
$this->assertSame(array(), $emptyList);
}

public function testLrange() {
$this->redis->cmd('RPUSH', 'range', 'one')
->cmd('RPUSH', 'range', 'two')
->cmd('RPUSH', 'range', 'three')
->set();

$this->assertSame(array('one'), $this->redis->cmd('LRANGE', 'range', '0', '0')->get());
$this->assertSame(array('one', 'two', 'three'), $this->redis->cmd('LRANGE', 'range', '-3', '2')->get());
$this->assertSame(array('one', 'two', 'three'), $this->redis->cmd('LRANGE', 'range', '-100', '100')->get());
$this->assertSame(array(), $this->redis->cmd('LRANGE', 'range', '5', '10')->get());
}

public function testTransactions() {

$this->redis->cmd('MULTI')->set();
$queued = $this->redis->cmd('SET', 'multi_foo', 'bar')->get();
$this->redis->cmd('EXEC')->set();

$value = $this->redis->cmd('GET', 'multi_foo')->get();

$this->assertSame('QUEUED', $queued);
$this->assertSame('bar', $value);
}

public function testTransactionsSingleLine() {

$this->redis->cmd('MULTI')->cmd('INCR', 'incr_foo')->cmd('EXPIRE', 'incr_foo', 100)->cmd('EXEC')->set();

$value = $this->redis->cmd('GET', 'incr_foo')->get();

$this->assertSame('1', $value);
}

protected function tearDown() {
$keys = array(
'foo',
'online_foo',
'online_bar',
'hash',
'set_structure',
'range',
'multi_foo',
'incr_foo',
);

foreach ($keys as $key) {
Expand Down

0 comments on commit cfe4360

Please sign in to comment.