Skip to content

Commit 46335f5

Browse files
committed
Merge branch 'master' into master-updates
Conflicts: tests/framework/extension_database_test_case.php
2 parents 9dad39a + a09ea47 commit 46335f5

1 file changed

Lines changed: 25 additions & 12 deletions

File tree

tests/framework/extension_database_test_case.php

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,52 @@
99

1010
abstract class extension_database_test_case extends phpbb_database_test_case
1111
{
12-
static protected $already_connected = false;
12+
protected $container;
13+
14+
public function get_container()
15+
{
16+
17+
if ($this->container === null)
18+
{
19+
global $phpbb_root_path, $phpEx;
20+
21+
// We must create a config file to be able to create the container
22+
$this->create_config_file($phpbb_root_path, $phpEx);
23+
24+
// Setup the container
25+
require_once($phpbb_root_path . 'includes/functions_container.' . $phpEx);
26+
$this->container = phpbb_create_default_container($phpbb_root_path, $phpEx);
27+
}
28+
29+
return $this->container;
30+
}
1331

1432
public function getConnection()
1533
{
1634
global $phpbb_root_path, $phpEx;
1735

36+
static $already_connected = false;
37+
1838
$config = $this->get_database_config();
1939

2040
$manager = $this->create_connection_manager($config);
2141

22-
if (!self::$already_connected)
42+
if (!$already_connected)
2343
{
2444
$manager->recreate_db();
2545
}
2646

2747
$manager->connect();
2848

29-
if (!self::$already_connected)
49+
if (!$already_connected)
3050
{
3151
// Install phpBB's schema
3252
$manager->load_schema($this->new_dbal());
3353

34-
// We must create a config file to be able to create the container
35-
$this->create_config_file($phpbb_root_path, $phpEx);
36-
37-
// Setup the container
38-
require_once($phpbb_root_path . 'includes/functions_container.' . $phpEx);
39-
$this->container = phpbb_create_default_container($phpbb_root_path, $phpEx);
40-
4154
// Setup some globals needed to add schema data and module data to the tables
4255
global $cache, $db, $phpbb_log, $phpbb_container;
4356

44-
$phpbb_container = $this->container;
57+
$phpbb_container = $this->get_container();
4558
$cache = $phpbb_container->get('cache');
4659
$db = $phpbb_container->get('dbal.conn');
4760
$phpbb_log = $phpbb_container->get('log');
@@ -100,7 +113,7 @@ public function getConnection()
100113
}
101114
}
102115

103-
self::$already_connected = true;
116+
$already_connected = true;
104117
}
105118

106119
return $this->createDefaultDBConnection($manager->get_pdo(), 'testdb');

0 commit comments

Comments
 (0)