1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-05 15:16:16 +02:00

[ticket/11997] Use path_helper in in foo/bar extension for redirect URLs

By using path_helper's clean_url() method, we'll be able to properly check
the full URL instead of just parts of the expected URL.

PHPBB3-11997
This commit is contained in:
Marc Alexander 2013-12-27 17:51:40 +01:00
parent a304d99b2b
commit 68ce16f9b3
3 changed files with 17 additions and 10 deletions

View File

@ -134,7 +134,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
$redirect = $crawler->filter('#redirect_' . $row_num)->text();
$redirect = substr($redirect, 0, strpos($redirect, 'sid') - 1);
$this->assertContains($crawler->filter('#redirect_expected_' . $row_num)->text(), $redirect);
$this->assertEquals($crawler->filter('#redirect_expected_' . $row_num)->text(), $redirect);
}
$this->phpbb_extension_manager->purge('foo/bar');

View File

@ -3,6 +3,7 @@ services:
class: foo\bar\controller\controller
arguments:
- @controller.helper
- @path_helper
- @template
- %core.root_path%
- %core.php_ext%

View File

@ -8,10 +8,11 @@ class controller
{
protected $template;
public function __construct(\phpbb\controller\helper $helper, \phpbb\template\template $template, $root_path, $php_ext)
public function __construct(\phpbb\controller\helper $helper, \phpbb\path_helper $path_helper, \phpbb\template\template $template, $root_path, $php_ext)
{
$this->template = $template;
$this->helper = $helper;
$this->path_helper = $path_helper;
$this->root_path = $root_path;
$this->php_ext = $php_ext;
}
@ -40,6 +41,7 @@ class controller
public function redirect()
{
$url_root = generate_board_url();
$redirects = array(
array(
append_sid($this->root_path . 'index.' . $this->php_ext),
@ -47,7 +49,7 @@ class controller
),
array(
append_sid($this->root_path . '../index.' . $this->php_ext),
'index.php',
'../index.php',
),
array(
append_sid($this->root_path . 'tests/index.' . $this->php_ext),
@ -55,7 +57,7 @@ class controller
),
array(
append_sid($this->root_path . '../tests/index.' . $this->php_ext),
'tests/index.php',
'../tests/index.php',
),
array(
$this->helper->url('index'),
@ -63,11 +65,11 @@ class controller
),
array(
$this->helper->url('../index'),
'app.php/index',
'index',
),
array(
$this->helper->url('../../index'),
'app.php/index',
'../index',
),
array(
$this->helper->url('tests/index'),
@ -75,15 +77,19 @@ class controller
),
array(
$this->helper->url('../tests/index'),
'app.php/tests/index',
'tests/index',
),
array(
$this->helper->url('../../tests/index'),
'app.php/tests/index',
'../tests/index',
),
array(
$this->helper->url('../tests/../index'),
'app.php/tests/index',
'index',
),
array(
$this->helper->url('tests/../index'),
'app.php/index',
),
);
@ -94,7 +100,7 @@ class controller
));
$this->template->assign_block_vars('redirects_expected', array(
'URL' => $redirect[1],
'URL' => $this->path_helper->clean_url($url_root . '/' . $redirect[1]),
));
}