mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/14462] Set instance of db driver for database access using global
PHPBB3-14462
This commit is contained in:
parent
d63b5a1315
commit
90710ffe98
1 changed files with 30 additions and 1 deletions
|
@ -27,6 +27,7 @@ class phpbb_ui_test_case extends phpbb_test_case
|
||||||
static protected $root_url;
|
static protected $root_url;
|
||||||
static protected $already_installed = false;
|
static protected $already_installed = false;
|
||||||
static protected $install_success = false;
|
static protected $install_success = false;
|
||||||
|
static protected $db;
|
||||||
|
|
||||||
static public function setUpBeforeClass()
|
static public function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
|
@ -83,6 +84,17 @@ class phpbb_ui_test_case extends phpbb_test_case
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
parent::tearDown();
|
||||||
|
|
||||||
|
if (self::$db instanceof \phpbb\db\driver\driver_interface)
|
||||||
|
{
|
||||||
|
// Close the database connections again this test
|
||||||
|
self::$db->sql_close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static public function visit($path)
|
static public function visit($path)
|
||||||
{
|
{
|
||||||
self::$webDriver->get(self::$root_url . $path);
|
self::$webDriver->get(self::$root_url . $path);
|
||||||
|
@ -107,10 +119,12 @@ class phpbb_ui_test_case extends phpbb_test_case
|
||||||
|
|
||||||
static public function install_board()
|
static public function install_board()
|
||||||
{
|
{
|
||||||
global $phpbb_root_path, $phpEx;
|
global $phpbb_root_path, $phpEx, $db;
|
||||||
|
|
||||||
self::recreate_database(self::$config);
|
self::recreate_database(self::$config);
|
||||||
|
|
||||||
|
$db = self::get_db();
|
||||||
|
|
||||||
$config_file = $phpbb_root_path . "config.$phpEx";
|
$config_file = $phpbb_root_path . "config.$phpEx";
|
||||||
$config_file_dev = $phpbb_root_path . "config_dev.$phpEx";
|
$config_file_dev = $phpbb_root_path . "config_dev.$phpEx";
|
||||||
$config_file_test = $phpbb_root_path . "config_test.$phpEx";
|
$config_file_test = $phpbb_root_path . "config_test.$phpEx";
|
||||||
|
@ -220,4 +234,19 @@ class phpbb_ui_test_case extends phpbb_test_case
|
||||||
$phpbb_container->reset();
|
$phpbb_container->reset();
|
||||||
unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template);
|
unset($phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static protected function get_db()
|
||||||
|
{
|
||||||
|
global $phpbb_root_path, $phpEx;
|
||||||
|
// so we don't reopen an open connection
|
||||||
|
if (!(self::$db instanceof \phpbb\db\driver\driver_interface))
|
||||||
|
{
|
||||||
|
$dbms = self::$config['dbms'];
|
||||||
|
/** @var \phpbb\db\driver\driver_interface $db */
|
||||||
|
$db = new $dbms();
|
||||||
|
$db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']);
|
||||||
|
self::$db = $db;
|
||||||
|
}
|
||||||
|
return self::$db;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue