mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 13:58:54 +00:00
Merge branch 'develop-ascraeus' into develop
This commit is contained in:
commit
cf71bfbdf2
6 changed files with 121 additions and 81 deletions
|
@ -101,6 +101,7 @@ services:
|
||||||
- @controller.provider
|
- @controller.provider
|
||||||
- @ext.manager
|
- @ext.manager
|
||||||
- @symfony_request
|
- @symfony_request
|
||||||
|
- @filesystem
|
||||||
- %core.root_path%
|
- %core.root_path%
|
||||||
- %core.php_ext%
|
- %core.php_ext%
|
||||||
|
|
||||||
|
|
|
@ -1989,6 +1989,9 @@ function tracking_unserialize($string, $max_depth = 3)
|
||||||
* @param mixed $params String or array of additional url parameters
|
* @param mixed $params String or array of additional url parameters
|
||||||
* @param bool $is_amp Is url using & (true) or & (false)
|
* @param bool $is_amp Is url using & (true) or & (false)
|
||||||
* @param string $session_id Possibility to use a custom session id instead of the global one
|
* @param string $session_id Possibility to use a custom session id instead of the global one
|
||||||
|
* @param bool $is_route Is url generated by a route.
|
||||||
|
*
|
||||||
|
* @return string The corrected url.
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* <code>
|
* <code>
|
||||||
|
@ -1999,7 +2002,7 @@ function tracking_unserialize($string, $max_depth = 3)
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
|
function append_sid($url, $params = false, $is_amp = true, $session_id = false, $is_route = false)
|
||||||
{
|
{
|
||||||
global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_path_helper;
|
global $_SID, $_EXTRA_URL, $phpbb_hook, $phpbb_path_helper;
|
||||||
global $phpbb_dispatcher;
|
global $phpbb_dispatcher;
|
||||||
|
@ -2011,7 +2014,7 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the root path with the correct relative web path
|
// Update the root path with the correct relative web path
|
||||||
if ($phpbb_path_helper instanceof \phpbb\path_helper)
|
if (!$is_route && $phpbb_path_helper instanceof \phpbb\path_helper)
|
||||||
{
|
{
|
||||||
$url = $phpbb_path_helper->update_web_root_path($url);
|
$url = $phpbb_path_helper->update_web_root_path($url);
|
||||||
}
|
}
|
||||||
|
@ -2037,9 +2040,10 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
|
||||||
* the global one (false)
|
* the global one (false)
|
||||||
* @var bool|string append_sid_overwrite Overwrite function (string
|
* @var bool|string append_sid_overwrite Overwrite function (string
|
||||||
* URL) or not (false)
|
* URL) or not (false)
|
||||||
|
* @var bool is_route Is url generated by a route.
|
||||||
* @since 3.1.0-a1
|
* @since 3.1.0-a1
|
||||||
*/
|
*/
|
||||||
$vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite');
|
$vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite', 'is_route');
|
||||||
extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars)));
|
extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars)));
|
||||||
|
|
||||||
if ($append_sid_overwrite)
|
if ($append_sid_overwrite)
|
||||||
|
|
|
@ -43,6 +43,11 @@ class helper
|
||||||
/* @var \phpbb\symfony_request */
|
/* @var \phpbb\symfony_request */
|
||||||
protected $symfony_request;
|
protected $symfony_request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \phpbb\filesystem The filesystem object
|
||||||
|
*/
|
||||||
|
protected $filesystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* phpBB root path
|
* phpBB root path
|
||||||
* @var string
|
* @var string
|
||||||
|
@ -64,15 +69,17 @@ class helper
|
||||||
* @param \phpbb\controller\provider $provider Path provider
|
* @param \phpbb\controller\provider $provider Path provider
|
||||||
* @param \phpbb\extension\manager $manager Extension manager object
|
* @param \phpbb\extension\manager $manager Extension manager object
|
||||||
* @param \phpbb\symfony_request $symfony_request Symfony Request object
|
* @param \phpbb\symfony_request $symfony_request Symfony Request object
|
||||||
|
* @param \phpbb\filesystem $filesystem The filesystem object
|
||||||
* @param string $phpbb_root_path phpBB root path
|
* @param string $phpbb_root_path phpBB root path
|
||||||
* @param string $php_ext PHP file extension
|
* @param string $php_ext PHP file extension
|
||||||
*/
|
*/
|
||||||
public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, $phpbb_root_path, $php_ext)
|
public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
$this->symfony_request = $symfony_request;
|
$this->symfony_request = $symfony_request;
|
||||||
|
$this->filesystem = $filesystem;
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->php_ext = $php_ext;
|
$this->php_ext = $php_ext;
|
||||||
$provider->find_routing_files($manager->get_finder());
|
$provider->find_routing_files($manager->get_finder());
|
||||||
|
@ -119,27 +126,34 @@ class helper
|
||||||
$anchor = '#' . $params['#'];
|
$anchor = '#' . $params['#'];
|
||||||
unset($params['#']);
|
unset($params['#']);
|
||||||
}
|
}
|
||||||
$url_generator = new UrlGenerator($this->route_collection, new RequestContext());
|
|
||||||
$route_url = $url_generator->generate($route, $params);
|
|
||||||
|
|
||||||
if (strpos($route_url, '/') === 0)
|
$context = new RequestContext();
|
||||||
{
|
$context->fromRequest($this->symfony_request);
|
||||||
$route_url = substr($route_url, 1);
|
|
||||||
}
|
$script_name = $this->symfony_request->getScriptName();
|
||||||
|
$page_name = substr($script_name, -1, 1) == '/' ? '' : utf8_basename($script_name);
|
||||||
|
|
||||||
|
$base_url = $context->getBaseUrl();
|
||||||
|
|
||||||
|
// If enable_mod_rewrite is false we need to replace the current front-end by app.php, otherwise we need to remove it.
|
||||||
|
$base_url = str_replace('/' . $page_name, empty($this->config['enable_mod_rewrite']) ? '/app.' . $this->php_ext : '', $base_url);
|
||||||
|
|
||||||
|
// We need to update the base url to move to the directory of the app.php file.
|
||||||
|
$base_url = str_replace('/app.' . $this->php_ext, '/' . $this->phpbb_root_path . 'app.' . $this->php_ext, $base_url);
|
||||||
|
|
||||||
|
$base_url = $this->filesystem->clean_path($base_url);
|
||||||
|
|
||||||
|
$context->setBaseUrl($base_url);
|
||||||
|
|
||||||
|
$url_generator = new UrlGenerator($this->route_collection, $context);
|
||||||
|
$route_url = $url_generator->generate($route, $params);
|
||||||
|
|
||||||
if ($is_amp)
|
if ($is_amp)
|
||||||
{
|
{
|
||||||
$route_url = str_replace(array('&', '&'), array('&', '&'), $route_url);
|
$route_url = str_replace(array('&', '&'), array('&', '&'), $route_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If enable_mod_rewrite is false, we need to include app.php
|
return append_sid($route_url . $anchor, false, $is_amp, $session_id, true);
|
||||||
$route_prefix = $this->phpbb_root_path;
|
|
||||||
if (empty($this->config['enable_mod_rewrite']))
|
|
||||||
{
|
|
||||||
$route_prefix .= 'app.' . $this->php_ext . '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
return append_sid($route_prefix . $route_url . $anchor, false, $is_amp, $session_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -21,11 +21,19 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||||
|
|
||||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
|
||||||
$this->user = new \phpbb\user('\phpbb\datetime');
|
$this->user = new \phpbb\user('\phpbb\datetime');
|
||||||
|
|
||||||
|
$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);
|
||||||
|
|
||||||
|
$this->symfony_request = new \phpbb\symfony_request(
|
||||||
|
$request
|
||||||
|
);
|
||||||
|
$this->filesystem = new \phpbb\filesystem();
|
||||||
$phpbb_path_helper = new \phpbb\path_helper(
|
$phpbb_path_helper = new \phpbb\path_helper(
|
||||||
new \phpbb\symfony_request(
|
$this->symfony_request,
|
||||||
new phpbb_mock_request()
|
$this->filesystem,
|
||||||
),
|
|
||||||
new \phpbb\filesystem(),
|
|
||||||
$this->getMock('\phpbb\request\request'),
|
$this->getMock('\phpbb\request\request'),
|
||||||
$phpbb_root_path,
|
$phpbb_root_path,
|
||||||
$phpEx
|
$phpEx
|
||||||
|
@ -78,30 +86,30 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||||
public function helper_url_data_no_rewrite()
|
public function helper_url_data_no_rewrite()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('controller2', array('t' => 1, 'f' => 2), true, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
|
array('controller2', array('t' => 1, 'f' => 2), true, false, '/app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
|
||||||
array('controller2', array('t' => 1, 'f' => 2), false, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
|
array('controller2', array('t' => 1, 'f' => 2), false, false, '/app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
|
||||||
|
|
||||||
// Custom sid parameter
|
// Custom sid parameter
|
||||||
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
||||||
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
||||||
|
|
||||||
// Testing anchors
|
// Testing anchors
|
||||||
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
||||||
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
||||||
|
|
||||||
// Anchors and custom sid
|
// Anchors and custom sid
|
||||||
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
||||||
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
||||||
|
|
||||||
// Empty parameters should not append the & or ?
|
// Empty parameters should not append the & or ?
|
||||||
array('controller2', array(), true, false, 'app.php/foo/bar', 'no params using empty array'),
|
array('controller2', array(), true, false, '/app.php/foo/bar', 'no params using empty array'),
|
||||||
array('controller2', array(), false, false, 'app.php/foo/bar', 'no params using empty array'),
|
array('controller2', array(), false, false, '/app.php/foo/bar', 'no params using empty array'),
|
||||||
array('controller3', array('p' => 3), true, false, 'app.php/foo/bar/p-3', 'no params using empty array'),
|
array('controller3', array('p' => 3), true, false, '/app.php/foo/bar/p-3', 'no params using empty array'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,37 +118,37 @@ 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)
|
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, '', '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, '', 'php', dirname(__FILE__) . '/');
|
||||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function helper_url_data_with_rewrite()
|
public function helper_url_data_with_rewrite()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('controller2', array('t' => 1, 'f' => 2), true, false, 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
|
array('controller2', array('t' => 1, 'f' => 2), true, false, '/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
|
||||||
array('controller2', array('t' => 1, 'f' => 2), false, false, 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
|
array('controller2', array('t' => 1, 'f' => 2), false, false, '/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
|
||||||
|
|
||||||
// Custom sid parameter
|
// Custom sid parameter
|
||||||
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
||||||
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
|
||||||
|
|
||||||
// Testing anchors
|
// Testing anchors
|
||||||
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
||||||
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
|
||||||
|
|
||||||
// Anchors and custom sid
|
// Anchors and custom sid
|
||||||
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
||||||
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
||||||
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
|
||||||
|
|
||||||
// Empty parameters should not append the & or ?
|
// Empty parameters should not append the & or ?
|
||||||
array('controller2', array(), true, false, 'foo/bar', 'no params using empty array'),
|
array('controller2', array(), true, false, '/foo/bar', 'no params using empty array'),
|
||||||
array('controller2', array(), false, false, 'foo/bar', 'no params using empty array'),
|
array('controller2', array(), false, false, '/foo/bar', 'no params using empty array'),
|
||||||
array('controller3', array('p' => 3), true, false, 'foo/bar/p-3', 'no params using empty array'),
|
array('controller3', array('p' => 3), true, false, '/foo/bar/p-3', 'no params using empty array'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +158,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)
|
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->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, '', '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, '', 'php', dirname(__FILE__) . '/');
|
||||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,13 @@
|
||||||
|
|
||||||
class phpbb_mock_controller_helper extends \phpbb\controller\helper
|
class phpbb_mock_controller_helper extends \phpbb\controller\helper
|
||||||
{
|
{
|
||||||
public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
|
public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
|
||||||
{
|
{
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->symfony_request = $symfony_request;
|
||||||
|
$this->filesystem = $filesystem;
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->php_ext = $php_ext;
|
$this->php_ext = $php_ext;
|
||||||
$provider->find_routing_files($manager->get_finder());
|
$provider->find_routing_files($manager->get_finder());
|
||||||
|
|
|
@ -34,9 +34,10 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
||||||
->method('lang')
|
->method('lang')
|
||||||
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
->will($this->returnCallback(array($this, 'return_callback_implode')));
|
||||||
|
|
||||||
|
$filesystem = new \phpbb\filesystem();
|
||||||
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
|
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
|
||||||
$finder = new \phpbb\finder(
|
$finder = new \phpbb\finder(
|
||||||
new \phpbb\filesystem(),
|
$filesystem,
|
||||||
dirname(__FILE__) . '/',
|
dirname(__FILE__) . '/',
|
||||||
new phpbb_mock_cache()
|
new phpbb_mock_cache()
|
||||||
);
|
);
|
||||||
|
@ -46,7 +47,17 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
||||||
$provider = new \phpbb\controller\provider();
|
$provider = new \phpbb\controller\provider();
|
||||||
$provider->find_routing_files($finder);
|
$provider->find_routing_files($finder);
|
||||||
$provider->find(dirname(__FILE__) . '/');
|
$provider->find(dirname(__FILE__) . '/');
|
||||||
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, '', 'php', dirname(__FILE__) . '/');
|
|
||||||
|
$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);
|
||||||
|
|
||||||
|
$symfony_request = new \phpbb\symfony_request(
|
||||||
|
$request
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, $symfony_request, $filesystem, '', 'php', dirname(__FILE__) . '/');
|
||||||
$this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper);
|
$this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,17 +121,17 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
||||||
:per_page:10
|
:per_page:10
|
||||||
:current_page:2
|
:current_page:2
|
||||||
:base_url:
|
:base_url:
|
||||||
:previous::test
|
:previous::/test
|
||||||
:else:1:test
|
:else:1:/test
|
||||||
:current:2:test/page/2
|
:current:2:/test/page/2
|
||||||
:else:3:test/page/3
|
:else:3:/test/page/3
|
||||||
:else:4:test/page/4
|
:else:4:/test/page/4
|
||||||
:else:5:test/page/5
|
:else:5:/test/page/5
|
||||||
:ellipsis:9:test/page/9
|
:ellipsis:9:/test/page/9
|
||||||
:else:10:test/page/10
|
:else:10:/test/page/10
|
||||||
:next::test/page/3
|
:next::/test/page/3
|
||||||
:u_prev:test
|
:u_prev:/test
|
||||||
:u_next:test/page/3',
|
:u_next:/test/page/3',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('routes' => array(
|
array('routes' => array(
|
||||||
|
@ -135,17 +146,17 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
|
||||||
:per_page:10
|
:per_page:10
|
||||||
:current_page:3
|
:current_page:3
|
||||||
:base_url:
|
:base_url:
|
||||||
:previous::test/page/2
|
:previous::/test/page/2
|
||||||
:else:1:test
|
:else:1:/test
|
||||||
:else:2:test/page/2
|
:else:2:/test/page/2
|
||||||
:current:3:test/page/3
|
:current:3:/test/page/3
|
||||||
:else:4:test/page/4
|
:else:4:/test/page/4
|
||||||
:else:5:test/page/5
|
:else:5:/test/page/5
|
||||||
:ellipsis:9:test/page/9
|
:ellipsis:9:/test/page/9
|
||||||
:else:10:test/page/10
|
:else:10:/test/page/10
|
||||||
:next::test/page/4
|
:next::/test/page/4
|
||||||
:u_prev:test/page/2
|
:u_prev:/test/page/2
|
||||||
:u_next:test/page/4',
|
:u_next:/test/page/4',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue