/**
  * {@inheritdoc}
  */
 public function create($parameters)
 {
     /** @var ConnectionWrapper $connection */
     $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;
 }
Beispiel #2
0
 /**
  * @group disconnected
  */
 public function testConstructorWithConnectionArgument()
 {
     $factory = new ConnectionFactory();
     $connection = $factory->create('tcp://localhost:7000');
     $client = new Client($connection);
     $this->assertInstanceOf('Predis\\Connection\\SingleConnectionInterface', $client->getConnection());
     $this->assertSame($connection, $client->getConnection());
     $parameters = $client->getConnection()->getParameters();
     $this->assertSame($parameters->host, 'localhost');
     $this->assertSame($parameters->port, 7000);
 }
 /**
  * @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');
 }