123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- namespace Predis\Command;
- class ListPushHeadTest extends PredisCommandTestCase
- {
-
- protected function getExpectedCommand()
- {
- return 'Predis\Command\ListPushHead';
- }
-
- protected function getExpectedId()
- {
- return 'LPUSH';
- }
-
- public function testFilterArguments()
- {
- $arguments = array('key', 'value1', 'value2', 'value3');
- $expected = array('key', 'value1', 'value2', 'value3');
- $command = $this->getCommand();
- $command->setArguments($arguments);
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testFilterArgumentsValuesAsSingleArray()
- {
- $arguments = array('key', array('value1', 'value2', 'value3'));
- $expected = array('key', 'value1', 'value2', 'value3');
- $command = $this->getCommand();
- $command->setArguments($arguments);
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testParseResponse()
- {
- $this->assertSame(1, $this->getCommand()->parseResponse(1));
- }
-
- public function testPrefixKeys()
- {
- $arguments = array('key', 'value1', 'value2', 'value3');
- $expected = array('prefix:key', 'value1', 'value2', 'value3');
- $command = $this->getCommandWithArgumentsArray($arguments);
- $command->prefixKeys('prefix:');
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testPrefixKeysIgnoredOnEmptyArguments()
- {
- $command = $this->getCommand();
- $command->prefixKeys('prefix:');
- $this->assertSame(array(), $command->getArguments());
- }
-
- public function testPushesElementsToHeadOfList()
- {
- $redis = $this->getClient();
-
- $this->assertSame(1, $redis->lpush('metavars', 'foo'));
- $this->assertSame(2, $redis->lpush('metavars', 'hoge'));
- $this->assertSame(array('hoge', 'foo'), $redis->lrange('metavars', 0, -1));
- }
-
- public function testThrowsExceptionOnWrongType()
- {
- $redis = $this->getClient();
- $redis->set('metavars', 'foo');
- $redis->lpush('metavars', 'hoge');
- }
- }
|