123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <?php
- namespace Predis\Command;
- use \PHPUnit_Framework_TestCase as StandardTestCase;
- class StringGetSetTest extends CommandTestCase
- {
-
- protected function getExpectedCommand()
- {
- return 'Predis\Command\StringGetSet';
- }
-
- protected function getExpectedId()
- {
- return 'GETSET';
- }
-
- public function testFilterArguments()
- {
- $arguments = array('key', 'value');
- $expected = array('key', 'value');
- $command = $this->getCommand();
- $command->setArguments($arguments);
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testParseResponse()
- {
- $this->assertSame('value', $this->getCommand()->parseResponse('value'));
- }
-
- public function testPrefixKeys()
- {
- $arguments = array('key', 'value');
- $expected = array('prefix:key', 'value');
- $command = $this->getCommandWithArgumentsArray($arguments);
- $command->prefixKeys('prefix:');
- $this->assertSame($expected, $command->getArguments());
- }
-
- public function testReturnsPreviousValueOfKey()
- {
- $redis = $this->getClient();
- $this->assertNull($redis->getset('foo', 'bar'));
- $this->assertSame('bar', $redis->getset('foo', 'barbar'));
- $redis->set('hoge', 'piyo');
- $this->assertSame('piyo', $redis->getset('hoge', 'piyopiyo'));
- }
-
- public function testThrowsExceptionOnWrongType()
- {
- $redis = $this->getClient();
- $redis->lpush('metavars', 'foo');
- $redis->getset('metavars', 'foo');
- }
- }
|