/** * {@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; }
/** * @group disconnected */ public function testConstructorWithConnectionArgument() { $factory = new Connection\Factory(); $connection = $factory->create('tcp://localhost:7000'); $client = new Client($connection); $this->assertInstanceOf('Predis\\Connection\\NodeConnectionInterface', $client->getConnection()); $this->assertSame($connection, $client->getConnection()); $parameters = $client->getConnection()->getParameters(); $this->assertSame($parameters->host, 'localhost'); $this->assertSame($parameters->port, 7000); }
/** * @group disconnected * @expectedException \InvalidArgumentException * @expecteExceptionMessage Unknown connection scheme: 'test'. */ public function testDefineAndUndefineConnection() { list(, $connectionClass) = $this->getMockConnectionClass(); $factory = new Factory(); $factory->define('test', $connectionClass); $this->assertInstanceOf($connectionClass, $factory->create('test://127.0.0.1')); $factory->undefine('test'); $factory->create('test://127.0.0.1'); }