mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/11590] Close database connections when tearDown() is called
PHPBB3-11590
This commit is contained in:
parent
6b6a07560e
commit
228c1075b7
1 changed files with 20 additions and 0 deletions
|
@ -11,6 +11,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||||
{
|
{
|
||||||
static private $already_connected;
|
static private $already_connected;
|
||||||
|
|
||||||
|
private $db_connections;
|
||||||
|
|
||||||
protected $test_case_helpers;
|
protected $test_case_helpers;
|
||||||
|
|
||||||
protected $fixture_xml_data;
|
protected $fixture_xml_data;
|
||||||
|
@ -28,6 +30,22 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||||
|
|
||||||
'phpbb_database_test_case' => array('already_connected'),
|
'phpbb_database_test_case' => array('already_connected'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->db_connections = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
|
||||||
|
// Close all database connections from this test
|
||||||
|
if (!empty($this->db_connections))
|
||||||
|
{
|
||||||
|
foreach ($this->db_connections as $db)
|
||||||
|
{
|
||||||
|
$db->sql_close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
|
@ -123,6 +141,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||||
$db = new $dbal();
|
$db = new $dbal();
|
||||||
$db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']);
|
$db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']);
|
||||||
|
|
||||||
|
$this->db_connections[] = $db;
|
||||||
|
|
||||||
return $db;
|
return $db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue