mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge pull request #1735 from nickvergessen/ticket/11852
Ticket/11852 filesystem class must not depend on a web request
This commit is contained in:
@@ -49,14 +49,15 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
|
||||
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
||||
$this->user = $this->getMock('\phpbb\user');
|
||||
$phpbb_filesystem = new \phpbb\filesystem(
|
||||
$phpbb_path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
);
|
||||
$this->template = new phpbb\template\twig\twig($phpbb_filesystem, $config, $this->user, new \phpbb\template\context());
|
||||
$this->template = new phpbb\template\twig\twig($phpbb_path_helper, $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'));
|
||||
@@ -101,14 +102,15 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
|
||||
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
||||
$this->user = $this->getMock('\phpbb\user');
|
||||
$phpbb_filesystem = new \phpbb\filesystem(
|
||||
$phpbb_path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
);
|
||||
$this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $this->user, new \phpbb\template\context());
|
||||
$this->template = new \phpbb\template\twig\twig($phpbb_path_helper, $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');
|
||||
|
@@ -59,13 +59,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
|
||||
$container,
|
||||
$this->db,
|
||||
$this->config,
|
||||
new phpbb\filesystem(
|
||||
new phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
dirname(__FILE__) . '/../../phpBB/',
|
||||
'php'
|
||||
),
|
||||
new phpbb\filesystem(),
|
||||
'phpbb_ext',
|
||||
dirname(__FILE__) . '/../../phpBB/',
|
||||
'php',
|
||||
|
@@ -114,13 +114,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
|
||||
$container,
|
||||
$db,
|
||||
$config,
|
||||
new \phpbb\filesystem(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
$phpbb_root_path,
|
||||
$php_ext
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
'phpbb_ext',
|
||||
dirname(__FILE__) . '/',
|
||||
$php_ext,
|
||||
|
@@ -41,10 +41,11 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
|
||||
$this->table_prefix = 'phpbb_';
|
||||
|
||||
$this->template = new \phpbb\template\twig\twig(
|
||||
new \phpbb\filesystem(
|
||||
new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$this->phpbb_root_path,
|
||||
$this->phpEx
|
||||
),
|
||||
@@ -70,13 +71,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
|
||||
$container,
|
||||
$this->db,
|
||||
$this->config,
|
||||
new \phpbb\filesystem(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
$this->phpbb_root_path,
|
||||
$this->phpEx
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
'phpbb_ext',
|
||||
$this->phpbb_root_path,
|
||||
$this->phpEx,
|
||||
|
@@ -14,13 +14,7 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->filesystem = new \phpbb\filesystem(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
dirname(__FILE__) . './../../phpBB/',
|
||||
'php'
|
||||
);
|
||||
$this->filesystem = new \phpbb\filesystem();
|
||||
}
|
||||
|
||||
public function clean_path_data()
|
||||
|
@@ -14,12 +14,6 @@ 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(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
$this->phpbb_root_path,
|
||||
$this->php_ext
|
||||
);
|
||||
$this->filesystem = new \phpbb\filesystem();
|
||||
}
|
||||
}
|
||||
|
@@ -7,9 +7,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_filesystem_web_root_path_test extends phpbb_test_case
|
||||
class phpbb_path_helper_web_root_path_test extends phpbb_test_case
|
||||
{
|
||||
protected $filesystem;
|
||||
protected $path_helper;
|
||||
protected $phpbb_root_path = '';
|
||||
|
||||
public function setUp()
|
||||
@@ -18,10 +18,11 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
|
||||
|
||||
$this->set_phpbb_root_path();
|
||||
|
||||
$this->filesystem = new \phpbb\filesystem(
|
||||
$this->path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$this->phpbb_root_path,
|
||||
'php'
|
||||
);
|
||||
@@ -43,7 +44,7 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
|
||||
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());
|
||||
$this->assertEquals($this->phpbb_root_path, $this->path_helper->get_web_root_path());
|
||||
}
|
||||
|
||||
public function basic_update_web_root_path_data()
|
||||
@@ -71,7 +72,7 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
|
||||
*/
|
||||
public function test_basic_update_web_root_path($input, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->filesystem->update_web_root_path($input, $symfony_request));
|
||||
$this->assertEquals($expected, $this->path_helper->update_web_root_path($input, $symfony_request));
|
||||
}
|
||||
|
||||
public function update_web_root_path_data()
|
||||
@@ -131,12 +132,13 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case
|
||||
->method('getScriptName')
|
||||
->will($this->returnValue($getScriptName));
|
||||
|
||||
$filesystem = new \phpbb\filesystem(
|
||||
$path_helper = new \phpbb\path_helper(
|
||||
$symfony_request,
|
||||
new \phpbb\filesystem(),
|
||||
$this->phpbb_root_path,
|
||||
'php'
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $filesystem->update_web_root_path($input, $symfony_request));
|
||||
$this->assertEquals($expected, $path_helper->update_web_root_path($input, $symfony_request));
|
||||
}
|
||||
}
|
@@ -116,14 +116,15 @@ Zeta test event in all',
|
||||
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
|
||||
dirname(__FILE__) . "/datasets/$dataset/"
|
||||
);
|
||||
$phpbb_filesystem = new \phpbb\filesystem(
|
||||
$path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
);
|
||||
$this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $user, new \phpbb\template\context, $this->extension_manager);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, new \phpbb\template\context, $this->extension_manager);
|
||||
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
|
||||
}
|
||||
}
|
||||
|
@@ -18,8 +18,8 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
|
||||
|
||||
// Prepare correct result
|
||||
$scripts = array(
|
||||
'<link href="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
|
||||
'<link href="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
|
||||
'<link href="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
|
||||
'<link href="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
|
||||
);
|
||||
|
||||
// Run test
|
||||
|
@@ -24,51 +24,51 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
|
||||
*/
|
||||
array(
|
||||
array('TEST' => 1),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=1"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 2),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=0"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=0"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 3),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 4),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 6),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?assets_version=1"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 7),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/child_only.js?assets_version=1"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 8),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 9),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 10),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 11),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.js?test1=1&test2=2&assets_version=1#test3"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/child_only.js?test1=1&test2=2&assets_version=1#test3"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 12),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1=1&test2=2&assets_version=1#test3"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1=1&test2=2&assets_version=1#test3"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 14),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1="&assets_version=1#test3"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1="&assets_version=1#test3"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 15),
|
||||
@@ -84,7 +84,7 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
|
||||
),
|
||||
array(
|
||||
array('TEST' => 18),
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&test2=0&assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&test2=0&assets_version=1"></script>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -63,16 +63,17 @@ 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(
|
||||
$path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
);
|
||||
|
||||
$this->template_path = $this->test_path . '/templates';
|
||||
$this->template = new \phpbb\template\twig\twig($phpbb_filesystem, $config, $this->user, new \phpbb\template\context());
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context());
|
||||
$this->template->set_custom_style('tests', $this->template_path);
|
||||
}
|
||||
|
||||
|
@@ -18,17 +18,18 @@ 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(
|
||||
$this->phpbb_path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$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($this->phpbb_filesystem, $config, $user, new phpbb\template\context());
|
||||
$this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, new phpbb\template\context());
|
||||
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
|
||||
}
|
||||
}
|
||||
|
@@ -203,13 +203,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
$container,
|
||||
$db,
|
||||
$config,
|
||||
new phpbb\filesystem(
|
||||
new phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
$phpbb_root_path,
|
||||
$php_ext
|
||||
),
|
||||
new phpbb\filesystem(),
|
||||
self::$config['table_prefix'] . 'ext',
|
||||
dirname(__FILE__) . '/',
|
||||
$php_ext,
|
||||
|
Reference in New Issue
Block a user