public function getConnection()
{
$config = getenv('DB_ADAPTER_MYSQLI_TEST_CONFIG');
- if ($config === false) {
- $config = dirname(__FILE__) . '/conf.php';
- }
- if (file_exists($config)) {
- require $config;
- }
- if (!isset($conf['db']['adapter']['mysqli']['test'])) {
- throw new Exception('No configuration for mysqli test.');
+ if ($config && !is_file($config)) {
+ $config = array_merge(array('host' => 'localhost', 'username' => '', 'password' => '', 'dbname' => 'test'), json_decode($config, true));
+ } else {
+ if (!$config) {
+ $config = dirname(__FILE__) . '/../conf.php';
+ }
+ if (file_exists($config)) {
+ require $config;
+ }
+ if (!isset($conf['db']['adapter']['mysqli']['test'])) {
+ throw new Exception('No configuration for mysqli test');
+ }
+ $config = $conf['db']['adapter']['mysqli']['test'];
}
- $conn = new Horde_Db_Adapter_Mysqli($conf['db']['adapter']['mysqli']['test']);
+ $conn = new Horde_Db_Adapter_Mysqli($config);
$cache = new Horde_Cache_Mock();
$conn->setCache($cache);
public function getConnection()
{
$config = getenv('DB_ADAPTER_PDO_MYSQL_TEST_CONFIG');
- if ($config === false) {
- $config = dirname(__FILE__) . '/../conf.php';
- }
- if (file_exists($config)) {
- require $config;
- }
- if (!isset($conf['db']['adapter']['pdo']['mysql']['test'])) {
- throw new Exception('No configuration for pdo mysql test.');
+ if ($config && !is_file($config)) {
+ $config = array_merge(array('host' => 'localhost', 'username' => '', 'password' => '', 'dbname' => 'test'), json_decode($config, true));
+ } else {
+ if (!$config) {
+ $config = dirname(__FILE__) . '/../conf.php';
+ }
+ if (file_exists($config)) {
+ require $config;
+ }
+ if (!isset($conf['db']['adapter']['pdo']['mysql']['test'])) {
+ throw new Exception('No configuration for pdo_mysql test');
+ }
+ $config = $conf['db']['adapter']['pdo']['mysql']['test'];
}
- $conn = new Horde_Db_Adapter_Pdo_Mysql($conf['db']['adapter']['pdo']['mysql']['test']);
+ $conn = new Horde_Db_Adapter_Pdo_Mysql($config);
$cache = new Horde_Cache_Mock();
$conn->setCache($cache);
{
$this->sharedFixture = $this;
}
-
}
if (!is_null(self::$conn)) { return self::$conn; }
$config = getenv('DB_ADAPTER_PDO_PGSQL_TEST_CONFIG');
- if ($config === false) {
- $config = dirname(__FILE__) . '/../conf.php';
- }
- if (file_exists($config)) {
- require $config;
- }
- if (!isset($conf['db']['adapter']['pdo']['pgsql']['test'])) {
- throw new Exception('No configuration for pdo pgsql test.');
+ if ($config && !is_file($config)) {
+ $config = array_merge(array('username' => '', 'password' => '', 'dbname' => 'test'), json_decode($config, true));
+ } else {
+ if (!$config) {
+ $config = dirname(__FILE__) . '/../conf.php';
+ }
+ if (file_exists($config)) {
+ require $config;
+ }
+ if (!isset($conf['db']['adapter']['pdo']['pgsql']['test'])) {
+ throw new Exception('No configuration for pdo_pgsql test');
+ }
+ $config = $conf['db']['adapter']['pdo']['pgsql']['test'];
}
- $conn = new Horde_Db_Adapter_Pdo_Pgsql($conf['db']['adapter']['pdo']['pgsql']['test']);
+ $conn = new Horde_Db_Adapter_Pdo_Pgsql($config);
$cache = new Horde_Cache_Mock();
$conn->setCache($cache);