From: Jan Schneider Date: Wed, 5 May 2010 13:50:31 +0000 (+0200) Subject: Make loading, naming, and overwriting of test backend configurations consistent. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=32dc5ebbd33c81df950a96689dc198de3067e21d;p=horde.git Make loading, naming, and overwriting of test backend configurations consistent. --- diff --git a/.gitignore b/.gitignore index 0f76b7853..bcfc0a964 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,8 @@ framework/*/test/*/*/*/*.out !framework/SyncML/tests/testpacket.php !framework/SyncML/tests/testsync.php !framework/XML_WBXML/tests/decode.php +framework/Db/test/Horde/Db/Adapter/conf.php +framework/Kolab_Storage/test/Horde/Kolab/Storage/conf.php # Dynamically generated content that may live in the repo directories /lib/ diff --git a/framework/Db/test/Horde/Db/Adapter/MysqliSuite.php b/framework/Db/test/Horde/Db/Adapter/MysqliSuite.php index 7cb4c1c15..fdec08064 100644 --- a/framework/Db/test/Horde/Db/Adapter/MysqliSuite.php +++ b/framework/Db/test/Horde/Db/Adapter/MysqliSuite.php @@ -62,17 +62,19 @@ class Horde_Db_Adapter_MysqliSuite extends PHPUnit_Framework_TestSuite if (!class_exists('CacheMock', false)) eval('class CacheMock { function get($key) { return $this->$key; } function set($key, $val) { $this->$key = $val; } } ?>'); $cache = new CacheMock; - $config = array( - 'host' => 'localhost', - 'username' => '', - 'password' => '', - 'dbname' => 'test', - 'cache' => $cache, - ); - if (isset($_ENV['HORDE_DB_TEST_DSN_MYSQLI'])) - $config = array_merge($config, @json_decode($_ENV['HORDE_DB_TEST_DSN_MYSQLI'], true)); + $config = getenv('DB_ADAPTER_MYSQLI_TEST_CONFIG'); + if ($config === false) { + $config = dirname(__FILE__) . '/conf.php'; + } + if (file_exists($config)) { + require $config; + $conf['db']['adapter']['mysqli']['test']['cache'] = $cache; + } + if (!isset($conf['db']['adapter']['mysqli']['test'])) { + throw new Exception('No configuration for mysqli test.'); + } - $conn = new Horde_Db_Adapter_Mysqli($config); + $conn = new Horde_Db_Adapter_Mysqli($conf['db']['adapter']['mysqli']['test']); return array($conn, $cache); } diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlSuite.php b/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlSuite.php index b3fc06f3b..25c73fd08 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlSuite.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlSuite.php @@ -62,17 +62,19 @@ class Horde_Db_Adapter_Pdo_MysqlSuite extends PHPUnit_Framework_TestSuite if (!class_exists('CacheMock', false)) eval('class CacheMock { function get($key) { return $this->$key; } function set($key, $val) { $this->$key = $val; } } ?>'); $cache = new CacheMock; - $config = array( - 'host' => 'localhost', - 'username' => '', - 'password' => '', - 'dbname' => 'test', - 'cache' => $cache, - ); - if (isset($_ENV['HORDE_DB_TEST_DSN_PDO_MYSQL'])) - $config = array_merge($config, @json_decode($_ENV['HORDE_DB_TEST_DSN_PDO_MYSQL'], true)); + $config = getenv('DB_ADAPTER_PDO_MYSQL_TEST_CONFIG'); + if ($config === false) { + $config = dirname(__FILE__) . '/../conf.php'; + } + if (file_exists($config)) { + require $config; + $conf['db']['adapter']['pdo']['mysql']['test']['cache'] = $cache; + } + if (!isset($conf['db']['adapter']['pdo']['mysql']['test'])) { + throw new Exception('No configuration for pdo mysql test.'); + } - $conn = new Horde_Db_Adapter_Pdo_Mysql($config); + $conn = new Horde_Db_Adapter_Pdo_Mysql($conf['db']['adapter']['pdo']['mysql']['test']); return array($conn, $cache); } diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php b/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php index f4b92e2d0..f6b8bff3c 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php @@ -65,16 +65,19 @@ class Horde_Db_Adapter_Pdo_PgsqlSuite extends PHPUnit_Framework_TestSuite if (!class_exists('CacheMock', false)) eval('class CacheMock { function get($key) { return $this->$key; } function set($key, $val) { $this->$key = $val; } } ?>'); $cache = new CacheMock; - $config = array( - 'username' => '', - 'password' => '', - 'dbname' => 'test', - 'cache' => $cache, - ); - if (isset($_ENV['HORDE_DB_TEST_DSN_PDO_PGSQL'])) - $config = array_merge($config, @json_decode($_ENV['HORDE_DB_TEST_DSN_PDO_PGSQL'], true)); + $config = getenv('DB_ADAPTER_PDO_PGSQL_TEST_CONFIG'); + if ($config === false) { + $config = dirname(__FILE__) . '/../conf.php'; + } + if (file_exists($config)) { + require $config; + $conf['db']['adapter']['pdo']['pgsql']['test']['cache'] = $cache; + } + if (!isset($conf['db']['adapter']['pdo']['pgsql']['test'])) { + throw new Exception('No configuration for pdo pgsql test.'); + } - $conn = new Horde_Db_Adapter_Pdo_Pgsql($config); + $conn = new Horde_Db_Adapter_Pdo_Pgsql($conf['db']['adapter']['pdo']['pgsql']['test']); return array($conn, $cache); } diff --git a/framework/Db/test/Horde/Db/Adapter/conf.php.dist b/framework/Db/test/Horde/Db/Adapter/conf.php.dist new file mode 100644 index 000000000..37daf954d --- /dev/null +++ b/framework/Db/test/Horde/Db/Adapter/conf.php.dist @@ -0,0 +1,12 @@ +