mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[ticket/11997] Add functional test for redirects in controller
PHPBB3-11997
This commit is contained in:
@@ -13,3 +13,7 @@ foo_template_controller:
|
||||
foo_exception_controller:
|
||||
pattern: /foo/exception
|
||||
defaults: { _controller: foo_bar.controller:exception }
|
||||
|
||||
foo_redirect_controller:
|
||||
pattern: /foo/redirect
|
||||
defaults: { _controller: foo_bar.controller:redirect }
|
||||
|
@@ -4,3 +4,5 @@ services:
|
||||
arguments:
|
||||
- @controller.helper
|
||||
- @template
|
||||
- %core.root_path%
|
||||
- %core.php_ext%
|
||||
|
@@ -8,10 +8,12 @@ class controller
|
||||
{
|
||||
protected $template;
|
||||
|
||||
public function __construct(\phpbb\controller\helper $helper, \phpbb\template\template $template)
|
||||
public function __construct(\phpbb\controller\helper $helper, \phpbb\template\template $template, $root_path, $php_ext)
|
||||
{
|
||||
$this->template = $template;
|
||||
$this->helper = $helper;
|
||||
$this->root_path = $root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
@@ -35,4 +37,30 @@ class controller
|
||||
{
|
||||
throw new \phpbb\controller\exception('Exception thrown from foo/exception route');
|
||||
}
|
||||
|
||||
public function redirect()
|
||||
{
|
||||
$redirects = array(
|
||||
append_sid($this->root_path . 'index.' . $this->php_ext),
|
||||
append_sid($this->root_path . '../index.' . $this->php_ext),
|
||||
append_sid($this->root_path . 'tests/index.' . $this->php_ext),
|
||||
append_sid($this->root_path . '../tests/index.' . $this->php_ext),
|
||||
$this->helper->url('index'),
|
||||
$this->helper->url('../index'),
|
||||
$this->helper->url('../../index'),
|
||||
$this->helper->url('tests/index'),
|
||||
$this->helper->url('../tests/index'),
|
||||
$this->helper->url('../../tests/index'),
|
||||
$this->helper->url('../tests/../index'),
|
||||
);
|
||||
|
||||
foreach ($redirects as $redirect)
|
||||
{
|
||||
$this->template->assign_block_vars('redirects', array(
|
||||
'URL' => redirect($redirect, true),
|
||||
));
|
||||
}
|
||||
|
||||
return $this->helper->render('redirect_body.html');
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,5 @@
|
||||
<!-- INCLUDE overall_header.html -->
|
||||
<!-- BEGIN redirects -->
|
||||
<div id="redirect_{redirects.S_ROW_COUNT}">{redirects.URL}</div>
|
||||
<!-- END redirects -->
|
||||
<!-- INCLUDE overall_footer.html -->
|
Reference in New Issue
Block a user