/** @internal */ private function __testbench_ndb_connectToDatabase(Connection $db, $databaseName = NULL) { //connect to an existing database other than $this->_databaseName $container = $this->__testbench_ndb_getContainer(); if ($databaseName === NULL) { $config = $container->parameters['testbench']; if (isset($config['dbname'])) { $databaseName = $config['dbname']; } elseif ($db->getSupplementalDriver() instanceof PgSqlDriver) { $databaseName = 'postgres'; } else { throw new \LogicException('You should setup existing database name using testbench:dbname option.'); } } $dsn = preg_replace('~dbname=[a-z0-9_-]+~i', "dbname={$databaseName}", $db->getDsn()); $dbr = $db->getReflection(); //:-( $params = $dbr->getProperty('params'); $params->setAccessible(TRUE); $params = $params->getValue($db); $options = $dbr->getProperty('options'); $options->setAccessible(TRUE); $options = $options->getValue($db); $db->disconnect(); $db->__construct($dsn, $params[1], $params[2], $options); $db->connect(); }