/**
  * @group disconnected
  */
 public function testDefineAndUndefineConnection()
 {
     list(, $connectionClass) = $this->getMockConnectionClass();
     $factory = new ConnectionFactory();
     $factory->define('redis', $connectionClass);
     $this->assertInstanceOf($connectionClass, $factory->create('redis://127.0.0.1'));
     $factory->undefine('redis');
     $this->setExpectedException('InvalidArgumentException', 'Unknown connection scheme: redis');
     $factory->create('redis://127.0.0.1');
 }
Beispiel #2
0
 private function createConnection($parameters)
 {
     $params = null;
     $connection = null;
     if ($parameters instanceof IConnectionSingle) {
         $connection = $parameters;
         $params = $connection->getParameters();
     } else {
         $params = $parameters instanceof ConnectionParameters ? $parameters : new ConnectionParameters($parameters);
         $connection = ConnectionFactory::create($params, $this->_responseReader);
     }
     return $this->pushInitCommands($connection, $params);
 }
Beispiel #3
0
 /**
  * @group disconnected
  */
 public function testConstructorWithReplicationArgument()
 {
     $replication = new MasterSlaveReplication();
     $factory = new ConnectionFactory();
     $factory->createReplication($replication, array('tcp://host1?alias=master', 'tcp://host2?alias=slave'));
     $client = new Client($replication);
     $this->assertInstanceOf('Predis\\Network\\IConnectionReplication', $client->getConnection());
     $this->assertSame($replication, $client->getConnection());
 }
Beispiel #4
0
 private function createConnection($parameters)
 {
     $params = $parameters instanceof ConnectionParameters ? $parameters : new ConnectionParameters($parameters);
     $connection = ConnectionFactory::create($params, $this->_responseReader);
     if ($params->password !== null) {
         $connection->pushInitCommand($this->createCommand('auth', array($params->password)));
     }
     if ($params->database !== null) {
         $connection->pushInitCommand($this->createCommand('changedb', array($params->database)));
     }
     return $connection;
 }
 /**
  * {@inheritdoc}
  */
 public function create($parameters, IServerProfile $profile = null)
 {
     $connection = parent::create($parameters, $profile);
     $connection = new LoggableConection($connection, $this->logger);
     return $connection;
 }
 /**
  * {@inheritdoc}
  */
 public function create($parameters, IServerProfile $profile = null)
 {
     $connection = parent::create($parameters);
     if ($connection->getParameters()->logging) {
         if (null !== $this->wrapper) {
             $wrapper = $this->wrapper;
             $connection = new $wrapper($connection);
         }
         $connection->setLogger($this->logger);
     }
     return $connection;
 }