From: Chuck Hagenbuch Date: Sun, 30 May 2010 14:06:50 +0000 (-0400) Subject: Fix unit tests after cache changes. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ca112b05fcd8d63561ca3c3eabf63c4ae4590b61;p=horde.git Fix unit tests after cache changes. --- diff --git a/framework/Db/test/Horde/Db/Adapter/MysqliSuite.php b/framework/Db/test/Horde/Db/Adapter/MysqliSuite.php index fdec08064..0f0c01619 100644 --- a/framework/Db/test/Horde/Db/Adapter/MysqliSuite.php +++ b/framework/Db/test/Horde/Db/Adapter/MysqliSuite.php @@ -59,22 +59,22 @@ class Horde_Db_Adapter_MysqliSuite extends PHPUnit_Framework_TestSuite public function getConnection() { - 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 = 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($conf['db']['adapter']['mysqli']['test']); + + $cache = new Horde_Cache_Mock(); + $conn->setCache($cache); + 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 25c73fd08..61da85af3 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlSuite.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/MysqlSuite.php @@ -59,22 +59,22 @@ class Horde_Db_Adapter_Pdo_MysqlSuite extends PHPUnit_Framework_TestSuite public function getConnection() { - 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 = 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($conf['db']['adapter']['pdo']['mysql']['test']); + + $cache = new Horde_Cache_Mock(); + $conn->setCache($cache); + 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 f6b8bff3c..32359b683 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php @@ -62,22 +62,22 @@ class Horde_Db_Adapter_Pdo_PgsqlSuite extends PHPUnit_Framework_TestSuite { if (!is_null(self::$conn)) { return self::$conn; } - 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 = 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($conf['db']['adapter']['pdo']['pgsql']['test']); + + $cache = new Horde_Cache_Mock(); + $conn->setCache($cache); + return array($conn, $cache); } diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteSuite.php b/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteSuite.php index e3641dcd2..cf5b2bc95 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteSuite.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteSuite.php @@ -59,14 +59,13 @@ class Horde_Db_Adapter_Pdo_SqliteSuite extends PHPUnit_Framework_TestSuite public function getConnection() { - if (!class_exists('CacheMock', false)) eval('class CacheMock { function get($key) { return $this->$key; } function set($key, $val) { $this->$key = $val; } } ?>'); - $cache = new CacheMock; - $conn = new Horde_Db_Adapter_Pdo_Sqlite(array( 'dbname' => ':memory:', - 'cache' => $cache, )); + $cache = new Horde_Cache_Mock(); + $conn->setCache($cache); + return array($conn, $cache); }