From: Chuck Hagenbuch Date: Thu, 7 Jan 2010 02:45:57 +0000 (-0500) Subject: Rework pdo_pgsql tests to not re-connect to the database every time; this seems X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=838a9ffd259a69e8c77d96e1e2d7251583e25cf3;p=horde.git Rework pdo_pgsql tests to not re-connect to the database every time; this seems to inevitably overflow the max_connections setting, at least on a developer-tuned postgres install. --- diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php b/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php index 7bd99977b..0c1f89e03 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlSuite.php @@ -24,6 +24,8 @@ */ class Horde_Db_Adapter_Pdo_PgsqlSuite extends PHPUnit_Framework_TestSuite { + public static $conn = null; + public static function suite() { $suite = new self('Horde Framework - Horde_Db - PDO-PostgreSQL Adapter'); @@ -31,9 +33,8 @@ class Horde_Db_Adapter_Pdo_PgsqlSuite extends PHPUnit_Framework_TestSuite $skip = true; if (extension_loaded('pdo') && in_array('pgsql', PDO::getAvailableDrivers())) { try { - list($conn,) = $suite->getConnection(); + self::$conn = $suite->getConnection(); $skip = false; - $conn->disconnect(); } catch (Exception $e) {} } @@ -59,6 +60,8 @@ class Horde_Db_Adapter_Pdo_PgsqlSuite extends PHPUnit_Framework_TestSuite public function getConnection() { + 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; diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php b/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php index 237f0e32d..233aa22d5 100644 --- a/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php +++ b/framework/Db/test/Horde/Db/Adapter/Pdo/PgsqlTest.php @@ -78,9 +78,6 @@ class Horde_Db_Adapter_Pdo_PgsqlTest extends PHPUnit_Framework_TestCase { // clean up $this->_dropTestTables(); - - // close connection - $this->_conn->disconnect(); } diff --git a/framework/Db/test/Horde/Db/Adapter/Postgresql/ColumnDefinitionTest.php b/framework/Db/test/Horde/Db/Adapter/Postgresql/ColumnDefinitionTest.php index 64c2854b2..3c40fc66f 100644 --- a/framework/Db/test/Horde/Db/Adapter/Postgresql/ColumnDefinitionTest.php +++ b/framework/Db/test/Horde/Db/Adapter/Postgresql/ColumnDefinitionTest.php @@ -29,13 +29,6 @@ class Horde_Db_Adapter_Postgresql_ColumnDefinitionTest extends PHPUnit_Framework list($this->_conn,) = $this->sharedFixture->getConnection(); } - protected function tearDown() - { - // close connection - $this->_conn->disconnect(); - } - - public function testConstruct() { $col = new Horde_Db_Adapter_Base_ColumnDefinition( diff --git a/framework/Db/test/Horde/Db/Adapter/Postgresql/TableDefinitionTest.php b/framework/Db/test/Horde/Db/Adapter/Postgresql/TableDefinitionTest.php index 52d18ab4c..327b82af6 100644 --- a/framework/Db/test/Horde/Db/Adapter/Postgresql/TableDefinitionTest.php +++ b/framework/Db/test/Horde/Db/Adapter/Postgresql/TableDefinitionTest.php @@ -29,12 +29,6 @@ class Horde_Db_Adapter_Postgresql_TableDefinitionTest extends PHPUnit_Framework_ list($this->_conn,) = $this->sharedFixture->getConnection(); } - protected function tearDown() - { - // close connection - $this->_conn->disconnect(); - } - /*########################################################################## # Public methods