diff --git a/phpBB/common.php b/phpBB/common.php
index 4f2c9ea272..fedf459888 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -47,7 +47,13 @@ if (!defined('PHPBB_INSTALLED'))
// Eliminate . and .. from the path
require($phpbb_root_path . 'phpbb/filesystem.' . $phpEx);
- $phpbb_filesystem = new \phpbb\filesystem();
+ $phpbb_filesystem = new phpbb\filesystem(
+ new phpbb\symfony\request(
+ new phpbb\request\request()
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
$script_path = $phpbb_filesystem->clean_path($script_path);
$url = (($secure) ? 'https://' : 'http://') . $server_name;
@@ -110,7 +116,8 @@ $db = $phpbb_container->get('dbal.conn');
request_var('', 0, false, false, $request); // "dependency injection" for a function
// Create a Symfony Request object from our phpbb_request object
-$symfony_request = phpbb_create_symfony_request($request);
+$symfony_request = $phpbb_container->get('symfony_request');
+$phpbb_filesystem = $phpbb_container->get('filesystem');
// Grab global variables, re-cache if necessary
$config = $phpbb_container->get('config');
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 5edaa6c0fc..f029ec40a3 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -169,6 +169,11 @@ services:
filesystem:
class: phpbb\filesystem
+ arguments:
+ - @symfony_request
+ - %core.root_path%
+ - %core.php_ext%
+ - %core.adm_relative_path%
groupposition.legend:
class: phpbb\groupposition\legend
@@ -252,16 +257,19 @@ services:
request:
class: phpbb\request\request
+ symfony_request:
+ class: phpbb_symfony_request
+ arguments:
+ - @request
+
template:
class: phpbb\template\twig\twig
arguments:
- - %core.root_path%
- - %core.php_ext%
+ - @filesystem
- @config
- @user
- @template_context
- @ext.manager
- - %core.adm_relative_path%
template_context:
class: phpbb\template\context
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php
index b6da41f9aa..f617b4b10a 100644
--- a/phpBB/includes/bbcode.php
+++ b/phpBB/includes/bbcode.php
@@ -126,13 +126,13 @@ class bbcode
*/
function bbcode_cache_init()
{
- global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager;
+ global $phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager, $phpbb_filesystem;
if (empty($this->template_filename))
{
$this->template_bitfield = new bitfield($user->style['bbcode_bitfield']);
- $template = new \phpbb\template\twig($phpbb_root_path, $phpEx, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
+ $template = new phpbb\template\twig\twig($phpbb_filesystem, $config, $user, new phpbb_template_context(), $phpbb_extension_manager);
$template->set_style();
$template->set_filenames(array('bbcode.html' => 'bbcode.html'));
$this->template_filename = $template->get_source_file_for_handle('bbcode.html');
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 03a4895433..53ee8c2512 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -7,8 +7,6 @@
*
*/
-use Symfony\Component\HttpFoundation\Request;
-
/**
* @ignore
*/
@@ -1072,7 +1070,14 @@ function phpbb_clean_path($path)
global $phpbb_root_path, $phpEx;
require($phpbb_root_path . 'includes/filesystem.' . $phpEx);
}
- $phpbb_filesystem = new \phpbb\filesystem();
+
+ $phpbb_filesystem = new phpbb\filesystem(
+ new phpbb\symfony\request(
+ new phpbb\request\request()
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
}
return $phpbb_filesystem->clean_path($path);
@@ -2410,9 +2415,8 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
*/
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
- global $_SID, $_EXTRA_URL, $phpbb_hook;
+ global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_filesystem;
global $phpbb_dispatcher;
- global $symfony_request, $phpbb_root_path;
if ($params === '' || (is_array($params) && empty($params)))
{
@@ -2420,10 +2424,10 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
$params = false;
}
- $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : '';
- if ($corrected_path)
+ // Update the root path with the correct relative web path
+ if ($phpbb_filesystem instanceof phpbb_filesystem)
{
- $url = substr($corrected_path . $url, strlen($phpbb_root_path));
+ $url = $phpbb_filesystem->update_web_root_path($url);
}
$append_sid_overwrite = false;
@@ -2815,8 +2819,22 @@ function build_url($strip_vars = false)
{
global $user, $phpbb_root_path;
+ $page = $user->page['page'];
+
+ // We need to be cautious here.
+ // On some situations, the redirect path is an absolute URL, sometimes a relative path
+ // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
+ // else we use the URL directly.
+ $url_parts = parse_url($page);
+
+ // URL
+ if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host']))
+ {
+ $page = $phpbb_root_path . $page;
+ }
+
// Append SID
- $redirect = append_sid($user->page['page'], false, false);
+ $redirect = append_sid($page, false, false);
// Add delimiter if not there...
if (strpos($redirect, '?') === false)
@@ -2871,19 +2889,7 @@ function build_url($strip_vars = false)
$redirect .= ($query) ? '?' . $query : '';
}
- // We need to be cautious here.
- // On some situations, the redirect path is an absolute URL, sometimes a relative path
- // For a relative path, let's prefix it with $phpbb_root_path to point to the correct location,
- // else we use the URL directly.
- $url_parts = @parse_url($redirect);
-
- // URL
- if ($url_parts !== false && !empty($url_parts['scheme']) && !empty($url_parts['host']))
- {
- return str_replace('&', '&', $redirect);
- }
-
- return $phpbb_root_path . str_replace('&', '&', $redirect);
+ return str_replace('&', '&', $redirect);
}
/**
@@ -5080,7 +5086,7 @@ function phpbb_build_hidden_fields_for_query_params($request, $exclude = null)
function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum')
{
global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path;
- global $phpbb_dispatcher, $request, $phpbb_container, $symfony_request;
+ global $phpbb_dispatcher, $request, $phpbb_container, $adm_relative_path;
if (defined('HEADER_INC'))
{
@@ -5240,7 +5246,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
// This path is sent with the base template paths in the assign_vars()
// call below. We need to correct it in case we are accessing from a
// controller because the web paths will be incorrect otherwise.
- $corrected_path = $symfony_request !== null ? phpbb_get_web_root_path($symfony_request, $phpbb_root_path) : '';
+ $phpbb_filesystem = $phpbb_container->get('filesystem');
+ $corrected_path = $phpbb_filesystem->get_web_root_path();
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $corrected_path;
// Send a proper content-language to the output
@@ -5322,7 +5329,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'SID' => $SID,
'_SID' => $_SID,
'SESSION_ID' => $user->session_id,
- 'ROOT_PATH' => $phpbb_root_path,
+ 'ROOT_PATH' => $web_path,
'BOARD_URL' => $board_url,
'L_LOGIN_LOGOUT' => $l_login_logout,
@@ -5378,7 +5385,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'S_FORUM_ID' => $forum_id,
'S_TOPIC_ID' => $topic_id,
- 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id)),
+ 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("{$phpbb_root_path}{$adm_relative_path}index.$phpEx", false, true, $user->session_id)),
'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => build_url())),
'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false,
@@ -5705,83 +5712,3 @@ function phpbb_convert_30_dbms_to_31($dbms)
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
}
-
-/**
-* Create a Symfony Request object from \phpbb\request\request object
-*
-* @param \phpbb\request\request $request Request object
-* @return Request A Symfony Request object
-*/
-function phpbb_create_symfony_request(\phpbb\request\request $request)
-{
- // If we have already gotten it, don't go back through all the trouble of
- // creating it again; instead, just return it. This allows multiple calls
- // of this method so we don't have to globalize $symfony_request in other
- // functions.
- static $symfony_request;
- if (null !== $symfony_request)
- {
- return $symfony_request;
- }
-
- // This function is meant to sanitize the global input arrays
- $sanitizer = function(&$value, $key) {
- $type_cast_helper = new \phpbb\request\type_cast_helper();
- $type_cast_helper->set_var($value, $value, gettype($value), true);
- };
-
- // We need to re-enable the super globals so we can access them here
- $request->enable_super_globals();
- $get_parameters = $_GET;
- $post_parameters = $_POST;
- $server_parameters = $_SERVER;
- $files_parameters = $_FILES;
- $cookie_parameters = $_COOKIE;
- // And now disable them again for security
- $request->disable_super_globals();
-
- array_walk_recursive($get_parameters, $sanitizer);
- array_walk_recursive($post_parameters, $sanitizer);
-
- $symfony_request = new Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
- return $symfony_request;
-}
-
-/**
-* Get a relative root path from the current URL
-*
-* @param Request $symfony_request Symfony Request object
-*/
-function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '')
-{
- global $phpbb_container;
-
- static $path;
- if (null !== $path)
- {
- return $path;
- }
-
- $path_info = $symfony_request->getPathInfo();
- if ($path_info === '/')
- {
- $path = $phpbb_root_path;
- return $path;
- }
-
- $filesystem = $phpbb_container->get('filesystem');
- $path_info = $filesystem->clean_path($path_info);
-
- // Do not count / at start of path
- $corrections = substr_count(substr($path_info, 1), '/');
-
- // When URL Rewriting is enabled, app.php is optional. We have to
- // correct for it not being there
- if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false)
- {
- $corrections -= 1;
- }
-
- $path = $phpbb_root_path . str_repeat('../', $corrections);
- return $path;
-}
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 05d3c5fde2..5fa37f60bd 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -813,7 +813,7 @@ function bbcode_nl2br($text)
*/
function smiley_text($text, $force_option = false)
{
- global $config, $user, $phpbb_root_path;
+ global $config, $user, $phpbb_filesystem;
if ($force_option || !$config['allow_smilies'] || !$user->optionget('viewsmilies'))
{
@@ -821,7 +821,7 @@ function smiley_text($text, $force_option = false)
}
else
{
- $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path;
+ $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_filesystem->get_web_root_path();
return preg_replace('#
subcompile($this->getNode('expr'))
->raw(";\n")
- ->write("\$asset = new \phpbb\\template\asset(\$asset_file);\n")
+ ->write("\$asset = new \phpbb\\template\\asset(\$asset_file, \$this->getEnvironment()->get_filesystem());\n")
->write("if (substr(\$asset_file, 0, 2) !== './' && \$asset->is_relative()) {\n")
->indent()
->write("\$asset_path = \$asset->get_path();")
diff --git a/phpBB/phpbb/template/twig/twig.php b/phpBB/phpbb/template/twig/twig.php
index 4856dd483e..2da7405743 100644
--- a/phpBB/phpbb/template/twig/twig.php
+++ b/phpBB/phpbb/template/twig/twig.php
@@ -32,6 +32,12 @@ class twig extends \phpbb\template\base
*/
private $cachepath = '';
+ /**
+ * phpBB filesystem
+ * @var \phpbb\filesystem
+ */
+ protected $phpbb_filesystem;
+
/**
* phpBB root path
* @var string
@@ -73,24 +79,23 @@ class twig extends \phpbb\template\base
/**
* Constructor.
*
- * @param string $phpbb_root_path phpBB root path
- * @param string $php_ext php extension (typically 'php')
+ * @param \phpbb\filesystem $phpbb_filesystem
* @param \phpbb\config\config $config
* @param \phpbb\user $user
* @param \phpbb\template\context $context template context
* @param \phpbb\extension\manager $extension_manager extension manager, if null then template events will not be invoked
- * @param string $adm_relative_path relative path to adm directory
*/
- public function __construct($phpbb_root_path, $php_ext, $config, $user, \phpbb\template\context $context, \phpbb\extension\manager $extension_manager = null, $adm_relative_path = null)
+ public function __construct(\phpbb\filesystem $phpbb_filesystem, $config, $user, \phpbb\template\context $context, \phpbb\extension\manager $extension_manager = null)
{
- $this->phpbb_root_path = $phpbb_root_path;
- $this->php_ext = $php_ext;
+ $this->phpbb_filesystem = $phpbb_filesystem;
+ $this->phpbb_root_path = $phpbb_filesystem->get_phpbb_root_path();
+ $this->php_ext = $phpbb_filesystem->get_php_ext();
$this->config = $config;
$this->user = $user;
$this->context = $context;
$this->extension_manager = $extension_manager;
- $this->cachepath = $phpbb_root_path . 'cache/twig/';
+ $this->cachepath = $this->phpbb_root_path . 'cache/twig/';
// Initiate the loader, __main__ namespace paths will be setup later in set_style_names()
$loader = new \phpbb\template\twig\loader('');
@@ -98,7 +103,7 @@ class twig extends \phpbb\template\base
$this->twig = new \phpbb\template\twig\environment(
$this->config,
($this->extension_manager) ? $this->extension_manager->all_enabled() : array(),
- $this->phpbb_root_path,
+ $this->phpbb_filesystem,
$loader,
array(
'cache' => (defined('IN_INSTALL')) ? false : $this->cachepath,
@@ -120,9 +125,9 @@ class twig extends \phpbb\template\base
$this->twig->setLexer($lexer);
// Add admin namespace
- if ($adm_relative_path !== null && is_dir($this->phpbb_root_path . $adm_relative_path . 'style/'))
+ if ($this->phpbb_filesystem->get_adm_relative_path() !== null && is_dir($this->phpbb_root_path . $this->phpbb_filesystem->get_adm_relative_path() . 'style/'))
{
- $this->twig->getLoader()->setPaths($this->phpbb_root_path . $adm_relative_path . 'style/', 'admin');
+ $this->twig->getLoader()->setPaths($this->phpbb_root_path . $this->phpbb_filesystem->get_adm_relative_path() . 'style/', 'admin');
}
}
diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php
index 9a75015c9f..6e53db9ba2 100644
--- a/tests/controller/helper_url_test.php
+++ b/tests/controller/helper_url_test.php
@@ -49,7 +49,14 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$this->user = $this->getMock('\phpbb\user');
- $this->template = new \phpbb\template\twig\twig($phpbb_root_path, $phpEx, $config, $this->user, new \phpbb\template\context());
+ $phpbb_filesystem = new \phpbb\filesystem(
+ new \phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
+ $this->template = new phpbb\template\twig\twig($phpbb_filesystem, $config, $this->user, new \phpbb\template\context());
// We don't use mod_rewrite in these tests
$config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
@@ -94,7 +101,14 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$this->user = $this->getMock('\phpbb\user');
- $this->template = new \phpbb\template\twig\twig($phpbb_root_path, $phpEx, $config, $this->user, new \phpbb\template\context());
+ $phpbb_filesystem = new \phpbb\filesystem(
+ new \phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
+ $this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $this->user, new \phpbb\template\context());
$config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
$helper = new \phpbb\controller\helper($this->template, $this->user, $config, '', 'php');
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index 6679ae407b..6481e09ead 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -59,7 +59,13 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$container,
$this->db,
$this->config,
- new \phpbb\filesystem(),
+ new phpbb\filesystem(
+ new phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ dirname(__FILE__) . '/../../phpBB/',
+ 'php'
+ ),
'phpbb_ext',
dirname(__FILE__) . '/../../phpBB/',
'php',
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index b127daf2ed..d694d298fa 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -114,7 +114,13 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$container,
$db,
$config,
- new \phpbb\filesystem(),
+ new \phpbb\filesystem(
+ new \phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ $phpbb_root_path,
+ $php_ext
+ ),
'phpbb_ext',
dirname(__FILE__) . '/',
$php_ext,
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 984ae63fa2..b68bf8e36a 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -41,8 +41,13 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->table_prefix = 'phpbb_';
$this->template = new \phpbb\template\twig\twig(
- $this->phpbb_root_path,
- $this->phpEx,
+ new \phpbb\filesystem(
+ new \phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ $this->phpbb_root_path,
+ $this->phpEx
+ ),
$this->config,
$this->user,
new \phpbb\template\context()
@@ -65,7 +70,13 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$container,
$this->db,
$this->config,
- new \phpbb\filesystem(),
+ new \phpbb\filesystem(
+ new \phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ $this->phpbb_root_path,
+ $this->phpEx
+ ),
'phpbb_ext',
$this->phpbb_root_path,
$this->phpEx,
diff --git a/tests/filesystem/clean_path_test.php b/tests/filesystem/clean_path_test.php
index fedadc103b..7fefcf2f90 100644
--- a/tests/filesystem/clean_path_test.php
+++ b/tests/filesystem/clean_path_test.php
@@ -14,7 +14,13 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case
public function setUp()
{
parent::setUp();
- $this->filesystem = new \phpbb\filesystem();
+ $this->filesystem = new \phpbb\filesystem(
+ new \phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ dirname(__FILE__) . './../../phpBB/',
+ 'php'
+ );
}
public function clean_path_data()
diff --git a/tests/filesystem/web_root_path_test.php b/tests/filesystem/web_root_path_test.php
new file mode 100644
index 0000000000..ae59d4f709
--- /dev/null
+++ b/tests/filesystem/web_root_path_test.php
@@ -0,0 +1,142 @@
+set_phpbb_root_path();
+
+ $this->filesystem = new phpbb_filesystem(
+ new phpbb_symfony_request(
+ new phpbb_mock_request()
+ ),
+ $this->phpbb_root_path,
+ 'php'
+ );
+ }
+
+ /**
+ * Set the phpbb_root_path
+ *
+ * This is necessary because dataProvider functions are called
+ * before setUp or setUpBeforeClass; so we must set the path
+ * any time we wish to use it in one of these functions (and
+ * also in general for everything else)
+ */
+ public function set_phpbb_root_path()
+ {
+ $this->phpbb_root_path = dirname(__FILE__) . './../../phpBB/';
+ }
+
+ public function test_get_web_root_path()
+ {
+ // Symfony Request = null, so always should return phpbb_root_path
+ $this->assertEquals($this->phpbb_root_path, $this->filesystem->get_web_root_path());
+ }
+
+ public function basic_update_web_root_path_data()
+ {
+ $this->set_phpbb_root_path();
+
+ return array(
+ array(
+ $this->phpbb_root_path . 'test.php',
+ $this->phpbb_root_path . 'test.php',
+ ),
+ array(
+ 'test.php',
+ $this->phpbb_root_path . 'test.php',
+ ),
+ array(
+ $this->phpbb_root_path . $this->phpbb_root_path . 'test.php',
+ $this->phpbb_root_path . $this->phpbb_root_path . 'test.php',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider basic_update_web_root_path_data
+ */
+ public function test_basic_update_web_root_path($input, $expected)
+ {
+ $this->assertEquals($expected, $this->filesystem->update_web_root_path($input, $symfony_request));
+ }
+
+ public function update_web_root_path_data()
+ {
+ $this->set_phpbb_root_path();
+
+ return array(
+ array(
+ $this->phpbb_root_path . 'test.php',
+ $this->phpbb_root_path . 'test.php',
+ '/',
+ ),
+ array(
+ $this->phpbb_root_path . 'test.php',
+ $this->phpbb_root_path . '../test.php',
+ '//',
+ ),
+ array(
+ $this->phpbb_root_path . 'test.php',
+ $this->phpbb_root_path . '../test.php',
+ '//',
+ 'foo/bar.php',
+ 'bar.php',
+ ),
+ array(
+ $this->phpbb_root_path . 'test.php',
+ $this->phpbb_root_path . '../../test.php',
+ '/foo/template',
+ '/phpbb3-fork/phpBB/app.php/foo/template',
+ '/phpbb3-fork/phpBB/app.php',
+ ),
+ array(
+ $this->phpbb_root_path . 'test.php',
+ $this->phpbb_root_path . '../test.php',
+ '/foo/template',
+ '/phpbb3-fork/phpBB/foo/template',
+ '/phpbb3-fork/phpBB/app.php',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider update_web_root_path_data
+ */
+ public function test_update_web_root_path($input, $expected, $getPathInfo, $getRequestUri = null, $getScriptName = null)
+ {
+ $symfony_request = $this->getMock("phpbb_symfony_request", array(), array(
+ new phpbb_mock_request(),
+ ));
+ $symfony_request->expects($this->any())
+ ->method('getPathInfo')
+ ->will($this->returnValue($getPathInfo));
+ $symfony_request->expects($this->any())
+ ->method('getRequestUri')
+ ->will($this->returnValue($getRequestUri));
+ $symfony_request->expects($this->any())
+ ->method('getScriptName')
+ ->will($this->returnValue($getScriptName));
+
+ $filesystem = new phpbb_filesystem(
+ $symfony_request,
+ $this->phpbb_root_path,
+ 'php'
+ );
+
+ $this->assertEquals($expected, $filesystem->update_web_root_path($input, $symfony_request));
+ }
+}
diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php
index 7049cbdc50..82065fc37d 100644
--- a/tests/mock/extension_manager.php
+++ b/tests/mock/extension_manager.php
@@ -14,6 +14,12 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = 'php';
$this->extensions = $extensions;
- $this->filesystem = new \phpbb\filesystem();
+ $this->filesystem = new \phpbb\filesystem(
+ new \phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ $this->phpbb_root_path,
+ $this->php_ext
+ );
}
}
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index 801f0055c8..41ece4972b 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -116,7 +116,14 @@ Zeta test event in all',
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
dirname(__FILE__) . "/datasets/$dataset/"
);
- $this->template = new \phpbb\template\twig\twig($phpbb_root_path, $phpEx, $config, $user, new \phpbb\template\context, $this->extension_manager);
+ $phpbb_filesystem = new \phpbb\filesystem(
+ new \phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
+ $this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $user, new \phpbb\template\context, $this->extension_manager);
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
}
}
diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php
index f8999ad1a9..c00aa8e9bb 100644
--- a/tests/template/template_includecss_test.php
+++ b/tests/template/template_includecss_test.php
@@ -18,8 +18,8 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
// Prepare correct result
$scripts = array(
- '',
- '',
+ '',
+ '',
);
// Run test
diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php
index b67fa123a1..2faeb5fcaa 100644
--- a/tests/template/template_includejs_test.php
+++ b/tests/template/template_includejs_test.php
@@ -13,6 +13,8 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
{
public function template_data()
{
+ $this->setup_engine();
+
return array(
/*
array(
@@ -22,51 +24,51 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
*/
array(
array('TEST' => 1),
- '',
+ '',
),
array(
array('TEST' => 2),
- '',
+ '',
),
array(
array('TEST' => 3),
- '',
+ '',
),
array(
array('TEST' => 4),
- '',
+ '',
),
array(
array('TEST' => 6),
- '',
+ '',
),
array(
array('TEST' => 7),
- '',
+ '',
),
array(
array('TEST' => 8),
- '',
+ '',
),
array(
array('TEST' => 9),
- '',
+ '',
),
array(
array('TEST' => 10),
- '',
+ '',
),
array(
array('TEST' => 11),
- '',
+ '',
),
array(
array('TEST' => 12),
- '',
+ '',
),
array(
array('TEST' => 14),
- '',
+ '',
),
array(
array('TEST' => 15),
@@ -82,7 +84,7 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
),
array(
array('TEST' => 18),
- '',
+ '',
),
);
}
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 7251151ef0..c9b38ee40d 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -63,8 +63,16 @@ class phpbb_template_template_test_case extends phpbb_test_case
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
$this->user = new \phpbb\user;
+ $phpbb_filesystem = new phpbb_filesystem(
+ new phpbb_symfony_request(
+ new phpbb_mock_request()
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
+
$this->template_path = $this->test_path . '/templates';
- $this->template = new \phpbb\template\twig\twig($phpbb_root_path, $phpEx, $config, $this->user, new \phpbb\template\context());
+ $this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $this->user, new \phpbb\template\context());
$this->template->set_custom_style('tests', $this->template_path);
}
diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php
index 438aa66471..7f7cffdb82 100644
--- a/tests/template/template_test_case_with_tree.php
+++ b/tests/template/template_test_case_with_tree.php
@@ -18,9 +18,17 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$defaults = $this->config_defaults();
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
+ $this->phpbb_filesystem = new phpbb_filesystem(
+ new phpbb_symfony_request(
+ new phpbb_mock_request()
+ ),
+ $phpbb_root_path,
+ $phpEx
+ );
+
$this->template_path = $this->test_path . '/templates';
$this->parent_template_path = $this->test_path . '/parent_templates';
- $this->template = new \phpbb\template\twig\twig($phpbb_root_path, $phpEx, $config, $user, new \phpbb\template\context());
+ $this->template = new phpbb\template\twig\twig($this->phpbb_filesystem, $config, $user, new phpbb\template\context());
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
}
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 3b13d35f97..f8ec125481 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -203,7 +203,13 @@ class phpbb_functional_test_case extends phpbb_test_case
$container,
$db,
$config,
- new \phpbb\filesystem(),
+ new phpbb\filesystem(
+ new phpbb\symfony\request(
+ new phpbb_mock_request()
+ ),
+ $phpbb_root_path,
+ $php_ext
+ ),
self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/',
$php_ext,