* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Predis\Command; /** * @group commands * @group realm-string */ class StringSetPreserveTest extends PredisCommandTestCase { /** * {@inheritdoc} */ protected function getExpectedCommand() { return 'Predis\Command\StringSetPreserve'; } /** * {@inheritdoc} */ protected function getExpectedId() { return 'SETNX'; } /** * @group disconnected */ public function testFilterArguments() { $arguments = array('foo', 'bar'); $expected = array('foo', 'bar'); $command = $this->getCommand(); $command->setArguments($arguments); $this->assertSame($expected, $command->getArguments()); } /** * @group disconnected */ public function testParseResponse() { $this->assertTrue($this->getCommand()->parseResponse(1)); } /** * @group disconnected */ public function testPrefixKeys() { $arguments = array('key', 'value'); $expected = array('prefix:key', 'value'); $command = $this->getCommandWithArgumentsArray($arguments); $command->prefixKeys('prefix:'); $this->assertSame($expected, $command->getArguments()); } /** * @group disconnected */ public function testPrefixKeysIgnoredOnEmptyArguments() { $command = $this->getCommand(); $command->prefixKeys('prefix:'); $this->assertSame(array(), $command->getArguments()); } /** * @group connected */ public function testSetStringValue() { $redis = $this->getClient(); $this->assertTrue($redis->setnx('foo', 'bar')); $this->assertFalse($redis->setnx('foo', 'barbar')); $this->assertEquals('bar', $redis->get('foo')); } }