function testCommandPipeline_ClientExceptionInCallableBlock()
 {
     $client = RC::getConnection();
     $client->flushdb();
     RC::testForClientException($this, 'TEST', function () use($client) {
         $client->pipeline(function ($pipe) {
             $pipe->ping();
             $pipe->set('foo', 'bar');
             throw new \Predis\ClientException("TEST");
         });
     });
     $this->assertFalse($client->exists('foo'));
 }
Example #2
0
 function testMultiExecContext_ClientExceptionInCallableBlock()
 {
     $client = RC::getConnection();
     $client->flushdb();
     RC::testForClientException($this, 'TEST', function () use($client) {
         $client->multiExec(function ($multi) {
             $multi->ping();
             $multi->set('foo', 'bar');
             throw new Predis\ClientException("TEST");
         });
     });
     $this->assertFalse($client->exists('foo'));
 }
 function testRedisServerProfile_CommandsCreation()
 {
     $profile = Predis_RedisServerProfile::get('1.0');
     $cmdNoArgs = $profile->createCommand('info');
     $this->assertInstanceOf('Predis_Compatibility_v1_0_Commands_Info', $cmdNoArgs);
     $this->assertNull($cmdNoArgs->getArgument());
     $args = array('key1', 'key2');
     $cmdWithArgs = $profile->createCommand('mget', $args);
     $this->assertInstanceOf('Predis_Compatibility_v1_0_Commands_GetMultiple', $cmdWithArgs);
     $this->assertEquals($args[0], $cmdWithArgs->getArgument());
     // TODO: why?
     $this->assertEquals($args[0], $cmdWithArgs->getArgument(0));
     $this->assertEquals($args[1], $cmdWithArgs->getArgument(1));
     $bogusCommand = 'not_existing_command';
     $expectedMessage = "'{$bogusCommand}' is not a registered Redis command";
     RC::testForClientException($this, $expectedMessage, p_anon("\$test", "\n            \$profile = Predis_RedisServerProfile::getDefault();\n            \$profile->createCommand('{$bogusCommand}');\n        "));
 }