aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bootstrap.php36
-rw-r--r--tests/functional/extension_controller_test.php6
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php20
3 files changed, 24 insertions, 38 deletions
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index e98ec384e6..302701e3b3 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -26,42 +26,6 @@ require_once 'test_framework/phpbb_test_case.php';
require_once 'test_framework/phpbb_database_test_case.php';
require_once 'test_framework/phpbb_database_test_connection_manager.php';
-// For functional tests, we need to make available the phpBB objects
-require_once $phpbb_root_path . 'config.php';
-// Setup class loader first
-$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
-$phpbb_class_loader_ext->register();
-$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
-$phpbb_class_loader->register();
-
-// set up caching
-$cache_factory = new phpbb_cache_factory($acm_type);
-$cache = $cache_factory->get_service();
-$phpbb_class_loader_ext->set_cache($cache->get_driver());
-$phpbb_class_loader->set_cache($cache->get_driver());
-
-// We have to include this because the class loader doesn't
-// recognize classes without the phpbb_ prefix
-// So user and auth and the DBAL aren't found unless we require these files
-require($phpbb_root_path . 'includes/session.' . $phpEx);
-require($phpbb_root_path . 'includes/auth.' . $phpEx);
-require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
-// Instantiate some basic classes
-$user = new user();
-$auth = new auth();
-$db = new $sql_db();
-
-$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
-
-// We do not need this any longer, unset for safety purposes
-unset($dbpasswd);
-
-// Grab global variables, re-cache if necessary
-$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
-
-// load extensions
-$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver());
-
if (version_compare(PHP_VERSION, '5.3.0-dev', '>='))
{
require_once 'test_framework/phpbb_functional_test_case.php';
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 430d93f9bf..7e50eb7d91 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -14,7 +14,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
{
public function setUp()
{
- global $phpbb_extension_manager;
+ parent::setUp();
+ $phpbb_extension_manager = $this->get_ext_manager();
$phpbb_extension_manager->enable('foobar');
$phpbb_extension_manager->enable('foo_bar');
@@ -24,7 +25,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
public function tearDown()
{
- global $phpbb_extension_manager;
+ parent::tearDown();
+ $phpbb_extension_manager = $this->get_ext_manager();
$phpbb_extension_manager->purge('foobar');
$phpbb_extension_manager->purge('foo_bar');
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index b5e6f7e377..b2ae215d91 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -66,6 +66,26 @@ class phpbb_functional_test_case extends phpbb_test_case
}
}
+ protected function get_db()
+ {
+ global $phpbb_root_path, $phpEx;
+ if (!class_exists('dbal_' . self::$config['dbms']))
+ {
+ include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx");
+ }
+ $sql_db = 'dbal_' . self::$config['dbms'];
+ $db = new $sql_db();
+ $db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']);
+ return $db;
+ }
+
+ protected function get_ext_manager()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_null);
+ }
+
protected function install_board()
{
global $phpbb_root_path, $phpEx;