mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge remote-tracking branch 'github-phpbb/develop' into ticket/11700
* github-phpbb/develop: [ticket/11832] Correct paths in tests [ticket/11832] Correct ROOT_PATH variable [ticket/11832] get_url() from phpbb_template_asset should return web path [ticket/11832] Fix INCLUDE(JS/CSS) [ticket/11832] Fix constructions of phpbb_filesystem [ticket/11832] Fix smiley paths [ticket/11832] Create phpbb_symfony_request to handle initiating symfony_request [ticket/11832] Fix build_url and the S_LOGIN_ACTION [ticket/11832] Changing comments to say app.php rather than index.php [ticket/11832] We must instantiate the $phpbb_filesystem in common [ticket/11832] Fix the web path corrections [ticket/11832] More extensive testing [ticket/11832] Use dirname(__FILE__) [ticket/11832] Use $phpbb_filesystem instead of the container in append_sid Revert "[ticket/11832] Make $phpbb_container a global initiated by the framework" [ticket/11832] Make $phpbb_container a global initiated by the framework [ticket/11832] Fix log tests [ticket/11832] update_web_root_path helper and tests [ticket/11832] Inject dependencies for phpbb_get_web_root_path (also moving) Conflicts: phpBB/common.php phpBB/config/services.yml phpBB/includes/bbcode.php phpBB/includes/functions.php phpBB/includes/functions_messenger.php phpBB/install/index.php phpBB/phpbb/filesystem.php phpBB/phpbb/template/twig/environment.php phpBB/phpbb/template/twig/node/includeasset.php phpBB/phpbb/template/twig/twig.php tests/controller/helper_url_test.php tests/dbal/migrator_test.php tests/extension/manager_test.php tests/extension/metadata_manager_test.php tests/filesystem/clean_path_test.php tests/mock/extension_manager.php tests/template/template_events_test.php tests/template/template_test_case.php tests/template/template_test_case_with_tree.php tests/test_framework/phpbb_functional_test_case.php
This commit is contained in:
@@ -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');
|
||||
|
@@ -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',
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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()
|
||||
|
142
tests/filesystem/web_root_path_test.php
Normal file
142
tests/filesystem/web_root_path_test.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_filesystem_web_root_path_test extends phpbb_test_case
|
||||
{
|
||||
protected $filesystem;
|
||||
protected $phpbb_root_path = '';
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->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));
|
||||
}
|
||||
}
|
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
@@ -18,8 +18,8 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
|
||||
|
||||
// Prepare correct result
|
||||
$scripts = array(
|
||||
'<link href="' . $this->test_path . '/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
|
||||
'<link href="' . $this->test_path . '/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
|
||||
'<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" />',
|
||||
);
|
||||
|
||||
// Run test
|
||||
|
@@ -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),
|
||||
'<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->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->test_path . '/templates/parent_and_child.js?assets_version=0"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->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->test_path . '/templates/parent_and_child.js?test=1&assets_version=0"></script>',
|
||||
'<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>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 4),
|
||||
'<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?test=1&assets_version=0"></script>',
|
||||
'<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>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 6),
|
||||
'<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->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->test_path . '/templates/child_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.js?assets_version=1"></script>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 8),
|
||||
'<script type="text/javascript" src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->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->test_path . '/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->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->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
|
||||
'<script type="text/javascript" src="' . $this->phpbb_filesystem->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->test_path . '/templates/child_only.js?test1=1&test2=2&assets_version=1#test3"></script>',
|
||||
'<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>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 12),
|
||||
'<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?test1=1&test2=2&assets_version=1#test3"></script>',
|
||||
'<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>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 14),
|
||||
'<script type="text/javascript" src="' . $this->test_path . '/parent_templates/parent_only.js?test1="&assets_version=1#test3"></script>',
|
||||
'<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>',
|
||||
),
|
||||
array(
|
||||
array('TEST' => 15),
|
||||
@@ -82,7 +84,7 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
|
||||
),
|
||||
array(
|
||||
array('TEST' => 18),
|
||||
'<script type="text/javascript" src="' . $this->test_path . '/templates/parent_and_child.js?test=1&test2=0&assets_version=1"></script>',
|
||||
'<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>',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user