From 6d2acb5ba3fbd22b345b312e704021eab1375941 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 24 Mar 2016 13:01:52 +0100 Subject: [PATCH] [ticket/13616] Fix UI tests PHPBB3-13616 --- phpBB/bin/phpbbcli.php | 2 ++ phpBB/common.php | 2 ++ phpBB/includes/compatibility_globals.php | 2 -- phpBB/phpbb/install/helper/container_factory.php | 3 +++ tests/test_framework/phpbb_ui_test_case.php | 12 ++++++++++-- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/phpBB/bin/phpbbcli.php b/phpBB/bin/phpbbcli.php index 72f1785931..804a7e09a0 100755 --- a/phpBB/bin/phpbbcli.php +++ b/phpBB/bin/phpbbcli.php @@ -68,6 +68,8 @@ $phpbb_container = $phpbb_container_builder->get_container(); $phpbb_container->get('request')->enable_super_globals(); require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); +register_compatibility_globals(); + /* @var $user \phpbb\user */ $user = $phpbb_container->get('user'); $user->data['user_id'] = ANONYMOUS; diff --git a/phpBB/common.php b/phpBB/common.php index 31972fe521..d12966168b 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -134,6 +134,8 @@ $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver')); require($phpbb_root_path . 'includes/compatibility_globals.' . $phpEx); +register_compatibility_globals(); + // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); diff --git a/phpBB/includes/compatibility_globals.php b/phpBB/includes/compatibility_globals.php index ae532c0f13..dc7a593693 100644 --- a/phpBB/includes/compatibility_globals.php +++ b/phpBB/includes/compatibility_globals.php @@ -75,5 +75,3 @@ function register_compatibility_globals() /* @var $template \phpbb\template\template */ $template = $phpbb_container->get('template'); } - -register_compatibility_globals(); diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index 5cf4f8a283..9e372fecde 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -183,6 +183,9 @@ class container_factory // Get compatibilty globals and constants $this->update_helper->include_file('includes/compatibility_globals.' . $this->php_ext); + + register_compatibility_globals(); + $this->update_helper->include_file('includes/constants.' . $this->php_ext); } } diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index b5ac3a576b..e79c78db29 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -256,9 +256,17 @@ class phpbb_ui_test_case extends phpbb_test_case @unlink($phpbb_root_path . 'cache/install_lock'); } - global $phpbb_container, $cache, $phpbb_dispatcher, $request, $user, $auth, $db, $config, $phpbb_log, $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $phpbb_extension_manager, $template; + global $phpbb_container; $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); + + $blacklist = ['phpbb_class_loader_mock', 'phpbb_class_loader_ext', 'phpbb_class_loader']; + + foreach (array_keys($GLOBALS) as $key) { + if (is_object($GLOBALS[$key]) && !in_array($key, $blacklist, true)) + { + unset($GLOBALS[$key]); + } + } } static protected function get_db()