aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-09-19 00:35:17 +0200
committerMarc Alexander <admin@m-a-styles.de>2014-09-19 00:35:17 +0200
commita6d9b42e5fa3912b3a559c7e2068e74d4927438a (patch)
tree4a9b64ac198df8c2a5b9c853affbda0344b17686
parentd74f45aee0164d6189c3bb4182d67f345b1d9d6e (diff)
downloadforums-a6d9b42e5fa3912b3a559c7e2068e74d4927438a.tar
forums-a6d9b42e5fa3912b3a559c7e2068e74d4927438a.tar.gz
forums-a6d9b42e5fa3912b3a559c7e2068e74d4927438a.tar.bz2
forums-a6d9b42e5fa3912b3a559c7e2068e74d4927438a.tar.xz
forums-a6d9b42e5fa3912b3a559c7e2068e74d4927438a.zip
[ticket/13073] Rework route tests and add tests for more directory types
PHPBB3-13073
-rw-r--r--tests/controller/helper_route_adm_subdir_test.php33
-rw-r--r--tests/controller/helper_route_adm_test.php45
-rw-r--r--tests/controller/helper_route_test.php54
-rw-r--r--tests/controller/helper_route_unclean_path_test.php33
4 files changed, 114 insertions, 51 deletions
diff --git a/tests/controller/helper_route_adm_subdir_test.php b/tests/controller/helper_route_adm_subdir_test.php
new file mode 100644
index 0000000000..783797f86a
--- /dev/null
+++ b/tests/controller/helper_route_adm_subdir_test.php
@@ -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__) . '/helper_route_test.php';
+
+class phpbb_controller_helper_route_adm_test extends phpbb_controller_helper_route_test
+{
+ protected function get_phpbb_root_path()
+ {
+ return './../../';
+ }
+
+ protected function get_uri()
+ {
+ return '/adm/subdir/index.php';
+ }
+
+ protected function get_script_name()
+ {
+ return 'index.php';
+ }
+}
diff --git a/tests/controller/helper_route_adm_test.php b/tests/controller/helper_route_adm_test.php
index ec7fc0c490..079f779dbf 100644
--- a/tests/controller/helper_route_adm_test.php
+++ b/tests/controller/helper_route_adm_test.php
@@ -14,45 +14,20 @@
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/helper_route_test.php';
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
-
class phpbb_controller_helper_route_adm_test extends phpbb_controller_helper_route_test
{
- public function setUp()
+ protected function get_phpbb_root_path()
{
- global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
-
- parent::setUp();
-
- $request = new phpbb_mock_request();
- $request->overwrite('SCRIPT_NAME', '/adm/index.php', \phpbb\request\request_interface::SERVER);
- $request->overwrite('SCRIPT_FILENAME', 'index.php', \phpbb\request\request_interface::SERVER);
- $request->overwrite('REQUEST_URI', '/adm/index.php', \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);
+ return './../';
+ }
- $this->symfony_request = new \phpbb\symfony_request(
- $request
- );
- $this->filesystem = new \phpbb\filesystem();
- $phpbb_path_helper = new \phpbb\path_helper(
- $this->symfony_request,
- $this->filesystem,
- $this->getMock('\phpbb\request\request'),
- $phpbb_root_path,
- $phpEx
- );
+ protected function get_uri()
+ {
+ return '/adm/index.php';
+ }
- $finder = new \phpbb\finder(
- new \phpbb\filesystem(),
- dirname(__FILE__) . '/',
- new phpbb_mock_cache()
- );
- $finder->set_extensions(array_keys($this->extension_manager->all_enabled()));
- $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 = './../';
+ protected function get_script_name()
+ {
+ return 'index.php';
}
}
diff --git a/tests/controller/helper_route_test.php b/tests/controller/helper_route_test.php
index 94e006166a..474230aa1c 100644
--- a/tests/controller/helper_route_test.php
+++ b/tests/controller/helper_route_test.php
@@ -23,13 +23,45 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
{
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');
+ $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
+ $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $this->user, new \phpbb\template\context());
+ }
+
+ 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);
@@ -37,25 +69,13 @@ 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->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, new \phpbb\template\context());
- $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/',
- ),
- )
- );
$finder = new \phpbb\finder(
new \phpbb\filesystem(),
@@ -66,6 +86,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()
diff --git a/tests/controller/helper_route_unclean_path_test.php b/tests/controller/helper_route_unclean_path_test.php
new file mode 100644
index 0000000000..697dda3c45
--- /dev/null
+++ b/tests/controller/helper_route_unclean_path_test.php
@@ -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__) . '/helper_route_test.php';
+
+class phpbb_controller_helper_route_adm_test extends phpbb_controller_helper_route_test
+{
+ protected function get_phpbb_root_path()
+ {
+ return './../';
+ }
+
+ protected function get_uri()
+ {
+ return '/adm/../bertie/index.php';
+ }
+
+ protected function get_script_name()
+ {
+ return 'index.php';
+ }
+}