mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-07 01:06:48 +02:00
Merge branch 'ticket/13073' into ticket/13073-develop
Conflicts: tests/controller/common_helper_route.php
This commit is contained in:
@@ -15,19 +15,49 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
abstract class phpbb_controller_common_helper_route extends phpbb_test_case
|
||||
{
|
||||
protected $root_path;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
|
||||
|
||||
$this->extension_manager = new phpbb_mock_extension_manager(
|
||||
dirname(__FILE__) . '/',
|
||||
array(
|
||||
'vendor2/foo' => array(
|
||||
'ext_name' => 'vendor2/foo',
|
||||
'ext_active' => '1',
|
||||
'ext_path' => 'ext/vendor2/foo/',
|
||||
),
|
||||
)
|
||||
);
|
||||
$this->generate_route_objects();
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
||||
$this->user = new \phpbb\user('\phpbb\datetime');
|
||||
}
|
||||
|
||||
protected function get_phpbb_root_path()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function get_uri()
|
||||
{
|
||||
return '/app.php';
|
||||
}
|
||||
|
||||
protected function get_script_name()
|
||||
{
|
||||
return 'app.php';
|
||||
}
|
||||
|
||||
protected function generate_route_objects()
|
||||
{
|
||||
$request = new phpbb_mock_request();
|
||||
$request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER);
|
||||
$request->overwrite('SCRIPT_FILENAME', 'app.php', \phpbb\request\request_interface::SERVER);
|
||||
$request->overwrite('REQUEST_URI', '/app.php', \phpbb\request\request_interface::SERVER);
|
||||
$request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER);
|
||||
$request->overwrite('SCRIPT_FILENAME', $this->get_script_name(), \phpbb\request\request_interface::SERVER);
|
||||
$request->overwrite('REQUEST_URI', $this->get_uri(), \phpbb\request\request_interface::SERVER);
|
||||
$request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER);
|
||||
$request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER);
|
||||
|
||||
@@ -35,14 +65,16 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
$request
|
||||
);
|
||||
$this->filesystem = new \phpbb\filesystem();
|
||||
$phpbb_path_helper = new \phpbb\path_helper(
|
||||
$this->phpbb_path_helper = new \phpbb\path_helper(
|
||||
$this->symfony_request,
|
||||
$this->filesystem,
|
||||
$this->getMock('\phpbb\request\request'),
|
||||
$phpbb_root_path,
|
||||
$phpEx
|
||||
);
|
||||
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
|
||||
$this->user = new \phpbb\user('\phpbb\datetime');
|
||||
|
||||
$container = new phpbb_mock_container_builder();
|
||||
$cache_path = $phpbb_root_path . 'cache/twig';
|
||||
@@ -50,7 +82,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
$loader = new \phpbb\template\twig\loader('');
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$this->config,
|
||||
$phpbb_path_helper,
|
||||
$this->phpbb_path_helper,
|
||||
$container,
|
||||
$cache_path,
|
||||
null,
|
||||
@@ -62,7 +94,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
|
||||
$this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
|
||||
$container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
|
||||
|
||||
$this->extension_manager = new phpbb_mock_extension_manager(
|
||||
@@ -85,6 +117,8 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
$this->provider = new \phpbb\controller\provider();
|
||||
$this->provider->find_routing_files($finder);
|
||||
$this->provider->find(dirname(__FILE__) . '/');
|
||||
// Set correct current phpBB root path
|
||||
$this->root_path = $this->get_phpbb_root_path();
|
||||
}
|
||||
|
||||
public function helper_url_data_no_rewrite()
|
||||
@@ -122,7 +156,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
*/
|
||||
public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
|
||||
{
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, '', 'php', dirname(__FILE__) . '/');
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
|
||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
||||
}
|
||||
|
||||
@@ -162,7 +196,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
|
||||
{
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, '', 'php', dirname(__FILE__) . '/');
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
|
||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
||||
}
|
||||
|
||||
@@ -202,7 +236,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description)
|
||||
{
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, '', 'php', dirname(__FILE__) . '/');
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
|
||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
@@ -242,7 +276,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description)
|
||||
{
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, '', 'php', dirname(__FILE__) . '/');
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
|
||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH));
|
||||
}
|
||||
|
||||
@@ -282,7 +316,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description)
|
||||
{
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, '', 'php', dirname(__FILE__) . '/');
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
|
||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH));
|
||||
}
|
||||
//TODO
|
||||
@@ -322,7 +356,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
|
||||
{
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, '', 'php', dirname(__FILE__) . '/');
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
|
||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL));
|
||||
}
|
||||
|
||||
@@ -362,7 +396,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
|
||||
{
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, '', 'php', dirname(__FILE__) . '/');
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
|
||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH));
|
||||
}
|
||||
|
||||
@@ -402,7 +436,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||
public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
|
||||
{
|
||||
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, '', 'php', dirname(__FILE__) . '/');
|
||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
|
||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH));
|
||||
}
|
||||
}
|
33
tests/controller/helper_route_adm_subdir_test.php
Normal file
33
tests/controller/helper_route_adm_subdir_test.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/common_helper_route.php';
|
||||
|
||||
class phpbb_controller_helper_route_adm_subdir_test extends phpbb_controller_common_helper_route
|
||||
{
|
||||
protected function get_phpbb_root_path()
|
||||
{
|
||||
return './../../';
|
||||
}
|
||||
|
||||
protected function get_uri()
|
||||
{
|
||||
return '/adm/subdir/index.php';
|
||||
}
|
||||
|
||||
protected function get_script_name()
|
||||
{
|
||||
return 'index.php';
|
||||
}
|
||||
}
|
33
tests/controller/helper_route_adm_test.php
Normal file
33
tests/controller/helper_route_adm_test.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/common_helper_route.php';
|
||||
|
||||
class phpbb_controller_helper_route_adm_test extends phpbb_controller_common_helper_route
|
||||
{
|
||||
protected function get_phpbb_root_path()
|
||||
{
|
||||
return './../';
|
||||
}
|
||||
|
||||
protected function get_uri()
|
||||
{
|
||||
return '/adm/index.php';
|
||||
}
|
||||
|
||||
protected function get_script_name()
|
||||
{
|
||||
return 'index.php';
|
||||
}
|
||||
}
|
33
tests/controller/helper_route_root_test.php
Normal file
33
tests/controller/helper_route_root_test.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/common_helper_route.php';
|
||||
|
||||
class phpbb_controller_helper_route_test extends phpbb_controller_common_helper_route
|
||||
{
|
||||
protected function get_phpbb_root_path()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function get_uri()
|
||||
{
|
||||
return '/app.php';
|
||||
}
|
||||
|
||||
protected function get_script_name()
|
||||
{
|
||||
return 'app.php';
|
||||
}
|
||||
}
|
33
tests/controller/helper_route_unclean_path_test.php
Normal file
33
tests/controller/helper_route_unclean_path_test.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/common_helper_route.php';
|
||||
|
||||
class phpbb_controller_helper_route_unclean_path_test extends phpbb_controller_common_helper_route
|
||||
{
|
||||
protected function get_phpbb_root_path()
|
||||
{
|
||||
return './../';
|
||||
}
|
||||
|
||||
protected function get_uri()
|
||||
{
|
||||
return '/adm/../bertie/index.php';
|
||||
}
|
||||
|
||||
protected function get_script_name()
|
||||
{
|
||||
return 'index.php';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user