diff options
Diffstat (limited to 'tests/functional')
5 files changed, 72 insertions, 2 deletions
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 37752b8fbb..ab90223c48 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -111,4 +111,35 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $this->assert_response_html(404); $this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text()); } + + /** + * Check the output of a controller using the template system + */ + public function test_redirect() + { + $filesystem = new \phpbb\filesystem(); + $this->phpbb_extension_manager->enable('foo/bar'); + $crawler = self::request('GET', 'app.php/foo/redirect'); + + $test_redirects = array( + 'index.php', + 'index.php', + 'tests/index.php', + 'tests/index.php', + 'app.php/index', + 'app.php/index', + 'app.php/index', + 'app.php/tests/index', + 'app.php/tests/index', + 'app.php/tests/index', + 'app.php/tests/index', + ); + + foreach ($test_redirects as $row_num => $redirect) + { + $this->assertContains($filesystem->clean_path(self::$root_url) . $redirect, $crawler->filter('#redirect_' . $row_num)->text()); + } + + $this->phpbb_extension_manager->purge('foo/bar'); + } } diff --git a/tests/functional/fixtures/ext/foo/bar/config/routing.yml b/tests/functional/fixtures/ext/foo/bar/config/routing.yml index 09a30a8c67..9b1ce3cfd7 100644 --- a/tests/functional/fixtures/ext/foo/bar/config/routing.yml +++ b/tests/functional/fixtures/ext/foo/bar/config/routing.yml @@ -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 } diff --git a/tests/functional/fixtures/ext/foo/bar/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml index 64e1163408..13aadf9768 100644 --- a/tests/functional/fixtures/ext/foo/bar/config/services.yml +++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml @@ -4,6 +4,9 @@ services: arguments: - @controller.helper - @template + - %core.root_path% + - %core.php_ext% + foo_bar.listener.permission: class: foo\bar\event\permission tags: @@ -12,4 +15,3 @@ services: class: foo\bar\event\user_setup tags: - { name: event.listener } - diff --git a/tests/functional/fixtures/ext/foo/bar/controller/controller.php b/tests/functional/fixtures/ext/foo/bar/controller/controller.php index 259d548299..ebb259af2f 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php @@ -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'); + } } diff --git a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/redirect_body.html b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/redirect_body.html new file mode 100644 index 0000000000..0c261f10ea --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/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 --> |