diff options
Diffstat (limited to 'tests/controller')
| -rw-r--r-- | tests/controller/common_helper_route.php | 421 | ||||
| -rw-r--r-- | tests/controller/config/routing.yml | 3 | ||||
| -rw-r--r-- | tests/controller/config/services.yml | 3 | ||||
| -rw-r--r-- | tests/controller/controller_test.php | 88 | ||||
| -rw-r--r-- | tests/controller/ext/vendor2/foo/config/routing.yml | 7 | ||||
| -rw-r--r-- | tests/controller/ext/vendor2/foo/config/routing_2.yml | 6 | ||||
| -rw-r--r-- | tests/controller/ext/vendor2/foo/config/services.yml | 3 | ||||
| -rw-r--r-- | tests/controller/ext/vendor2/foo/controller.php | 18 | ||||
| -rw-r--r-- | tests/controller/ext/vendor2/foo/subfolder/config/routing.yml | 3 | ||||
| -rw-r--r-- | tests/controller/helper_route_adm_subdir_test.php | 33 | ||||
| -rw-r--r-- | tests/controller/helper_route_adm_test.php | 33 | ||||
| -rw-r--r-- | tests/controller/helper_route_other_app.php | 37 | ||||
| -rw-r--r-- | tests/controller/helper_route_root_test.php | 33 | ||||
| -rw-r--r-- | tests/controller/helper_route_slash_test.php | 43 | ||||
| -rw-r--r-- | tests/controller/helper_route_unclean_path_test.php | 33 | ||||
| -rw-r--r-- | tests/controller/phpbb/controller/foo.php | 18 | 
16 files changed, 782 insertions, 0 deletions
| diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php new file mode 100644 index 0000000000..ff1af8119b --- /dev/null +++ b/tests/controller/common_helper_route.php @@ -0,0 +1,421 @@ +<?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'; + +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; + +abstract class phpbb_controller_common_helper_route extends phpbb_test_case +{ +	protected $root_path; + +	public function setUp() +	{ +		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_base_uri() +	{ +		return $this->get_uri(); +	} + +	protected function get_script_name() +	{ +		return 'app.php'; +	} + +	protected function path_to_app() +	{ +		return ''; +	} + +	protected function generate_route_objects() +	{ +		$this->request = new phpbb_mock_request(); +		$this->request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER); +		$this->request->overwrite('SCRIPT_FILENAME', $this->get_script_name(), \phpbb\request\request_interface::SERVER); +		$this->request->overwrite('REQUEST_URI', $this->get_base_uri(), \phpbb\request\request_interface::SERVER); +		$this->request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER); +		$this->request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER); + +		$this->symfony_request = new \phpbb\symfony_request( +			$this->request +		); +		$this->filesystem = new \phpbb\filesystem(); +		$this->phpbb_path_helper = new \phpbb\path_helper( +			$this->symfony_request, +			$this->filesystem, +			$this->request, +			$phpbb_root_path, +			$phpEx +		); + +		$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 = $this->get_phpbb_root_path(); +	} + +	public function helper_url_data_no_rewrite() +	{ +		return array( +			array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'), +			array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . '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, '/' . $this->path_to_app() . '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, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + +			// Custom sid parameter +			array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . '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', '/' . $this->path_to_app() . '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', '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + +			// Testing anchors +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . $this->path_to_app() . '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, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'), + +			// Anchors and custom sid +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . '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', '/' . $this->path_to_app() . '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', '/' . $this->path_to_app() . '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 ? +			array('controller2', array(), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), +			array('controller2', array(), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), +			array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'), +		); +	} + +	/** +	* @dataProvider helper_url_data_no_rewrite() +	*/ +	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, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); +		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); +	} + +	public function helper_url_data_with_rewrite() +	{ +		return array( +			array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'), +			array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'), +			array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . '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, '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + +			// Custom sid parameter +			array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . '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', '/' . $this->path_to_app() . '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', '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + +			// Testing anchors +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), +			array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'), + +			// Anchors and custom sid +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . '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', '/' . $this->path_to_app() . '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', '/' . $this->path_to_app() . '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 ? +			array('controller2', array(), true, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), +			array('controller2', array(), false, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), +			array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'), +		); +	} + +	/** +	* @dataProvider helper_url_data_with_rewrite() +	*/ +	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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); +		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); +	} + +	public function helper_url_data_absolute() +	{ +		return array( +			array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'), +			array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . '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, 'http://localhost/' . $this->path_to_app() . '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, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + +			// Custom sid parameter +			array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . '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', 'http://localhost/' . $this->path_to_app() . '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', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + +			// Testing anchors +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . $this->path_to_app() . '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, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'), + +			// Anchors and custom sid +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . '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', 'http://localhost/' . $this->path_to_app() . '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', 'http://localhost/' . $this->path_to_app() . '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 ? +			array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), +			array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), +			array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'), +		); +	} + +	/** +	* @dataProvider helper_url_data_absolute() +	*/ +	public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description) +	{ +		$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); +		$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); +		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL)); +	} + +	public function helper_url_data_relative_path() +	{ +		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), 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), false, false, 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + +			// 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), 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'), + +			// 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'), 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)'), + +			// 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'), 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'), + +			// Empty parameters should not append the & or ? +			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('controller3', array('p' => 3), true, false, 'app.php/foo/bar/p-3', 'no params using empty array'), +		); +	} + +	/** +	* @dataProvider helper_url_data_relative_path() +	*/ +	public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description) +	{ +		$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); +		$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); +		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH)); +	} + +	public function helper_url_data_network() +	{ +		return array( +			array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'), +			array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . '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, '//localhost/' . $this->path_to_app() . '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, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + +			// Custom sid parameter +			array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . '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', '//localhost/' . $this->path_to_app() . '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', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + +			// Testing anchors +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . $this->path_to_app() . '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, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'), + +			// Anchors and custom sid +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . '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', '//localhost/' . $this->path_to_app() . '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', '//localhost/' . $this->path_to_app() . '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 ? +			array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), +			array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'), +			array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'), +		); +	} + +	/** +	* @dataProvider helper_url_data_network() +	*/ +	public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description) +	{ +		$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); +		$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); +		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH)); +	} +//TODO +	public function helper_url_data_absolute_with_rewrite() +	{ +		return array( +			array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'), +			array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'), +			array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . '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, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + +			// Custom sid parameter +			array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . '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', 'http://localhost/' . $this->path_to_app() . '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', 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + +			// Testing anchors +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), +			array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'), + +			// Anchors and custom sid +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . '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', 'http://localhost/' . $this->path_to_app() . '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', 'http://localhost/' . $this->path_to_app() . '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 ? +			array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), +			array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), +			array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'), +		); +	} + +	/** +	 * @dataProvider helper_url_data_absolute_with_rewrite() +	 */ +	public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) +	{ +		$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, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); +		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL)); +	} + +	public function helper_url_data_relative_path_with_rewrite() +	{ +		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), 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), false, false, 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + +			// 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), 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'), + +			// 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'), 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)'), + +			// 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'), 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'), + +			// Empty parameters should not append the & or ? +			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('controller3', array('p' => 3), true, false, 'foo/bar/p-3', 'no params using empty array'), +		); +	} + +	/** +	 * @dataProvider helper_url_data_relative_path_with_rewrite() +	 */ +	public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) +	{ +		$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, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); +		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH)); +	} + +	public function helper_url_data_network_with_rewrite() +	{ +		return array( +			array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'), +			array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'), +			array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . '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, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + +			// Custom sid parameter +			array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . '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', '//localhost/' . $this->path_to_app() . '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', '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + +			// Testing anchors +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), +			array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'), + +			// Anchors and custom sid +			array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . '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', '//localhost/' . $this->path_to_app() . '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', '//localhost/' . $this->path_to_app() . '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 ? +			array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), +			array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'), +			array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'), +		); +	} + +	/** +	 * @dataProvider helper_url_data_network_with_rewrite() +	 */ +	public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) +	{ +		$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, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); +		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH)); +	} +} diff --git a/tests/controller/config/routing.yml b/tests/controller/config/routing.yml new file mode 100644 index 0000000000..1e7df02684 --- /dev/null +++ b/tests/controller/config/routing.yml @@ -0,0 +1,3 @@ +core_controller: +    path: /core_foo +    defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/config/services.yml b/tests/controller/config/services.yml new file mode 100644 index 0000000000..e4412af3d7 --- /dev/null +++ b/tests/controller/config/services.yml @@ -0,0 +1,3 @@ +services: +    core_foo.controller: +        class: phpbb\controller\foo diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php new file mode 100644 index 0000000000..62feee3fed --- /dev/null +++ b/tests/controller/controller_test.php @@ -0,0 +1,88 @@ +<?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'; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; + +class phpbb_controller_controller_test extends phpbb_test_case +{ +	public function setUp() +	{ +		$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/', +				), +			)); +	} + +	public function test_provider() +	{ +		$provider = new \phpbb\controller\provider(); +		$provider->find_routing_files($this->extension_manager->get_finder()); +		$routes = $provider->find(__DIR__)->get_routes(); + +		// This will need to be updated if any new routes are defined +		$this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('core_controller')); +		$this->assertEquals('/core_foo', $routes->get('core_controller')->getPath()); + +		$this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller1')); +		$this->assertEquals('/foo', $routes->get('controller1')->getPath()); + +		$this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller2')); +		$this->assertEquals('/foo/bar', $routes->get('controller2')->getPath()); + +		$this->assertNull($routes->get('controller_noroute')); +	} + +	public function test_controller_resolver() +	{ +		$container = new ContainerBuilder(); +		// YamlFileLoader only uses one path at a time, so we need to loop +		// through all of the ones we are using. +		foreach (array(__DIR__.'/config', __DIR__ . '/ext/vendor2/foo/config') as $path) +		{ +			$loader = new YamlFileLoader($container, new FileLocator($path)); +			$loader->load('services.yml'); +		} + +		// Autoloading classes within the tests folder does not work +		// so I'll include them manually. +		if (!class_exists('vendor2\\foo\\controller')) +		{ +			include(__DIR__ . '/ext/vendor2/foo/controller.php'); +		} +		if (!class_exists('phpbb\\controller\\foo')) +		{ +			include(__DIR__.'/phpbb/controller/foo.php'); +		} + +		$resolver = new \phpbb\controller\resolver(new \phpbb\user('\phpbb\datetime'), $container, dirname(__FILE__) . '/'); +		$symfony_request = new Request(); +		$symfony_request->attributes->set('_controller', 'foo.controller:handle'); + +		$this->assertEquals($resolver->getController($symfony_request), array(new foo\controller, 'handle')); + +		$symfony_request = new Request(); +		$symfony_request->attributes->set('_controller', 'core_foo.controller:bar'); + +		$this->assertEquals($resolver->getController($symfony_request), array(new phpbb\controller\foo, 'bar')); +	} +} diff --git a/tests/controller/ext/vendor2/foo/config/routing.yml b/tests/controller/ext/vendor2/foo/config/routing.yml new file mode 100644 index 0000000000..e3e8ee5f98 --- /dev/null +++ b/tests/controller/ext/vendor2/foo/config/routing.yml @@ -0,0 +1,7 @@ +controller1: +    path: /foo +    defaults: { _controller: foo.controller:handle } + +include_controller2: +    resource: "routing_2.yml" +    prefix:   /foo diff --git a/tests/controller/ext/vendor2/foo/config/routing_2.yml b/tests/controller/ext/vendor2/foo/config/routing_2.yml new file mode 100644 index 0000000000..ee05898c66 --- /dev/null +++ b/tests/controller/ext/vendor2/foo/config/routing_2.yml @@ -0,0 +1,6 @@ +controller2: +    path: /bar +    defaults: { _controller: foo.controller:handle } +controller3: +    path: /bar/p-{p} +    defaults: { _controller: foo.controller:handle } diff --git a/tests/controller/ext/vendor2/foo/config/services.yml b/tests/controller/ext/vendor2/foo/config/services.yml new file mode 100644 index 0000000000..9ed67d5bc2 --- /dev/null +++ b/tests/controller/ext/vendor2/foo/config/services.yml @@ -0,0 +1,3 @@ +services: +    foo.controller: +        class: foo\controller diff --git a/tests/controller/ext/vendor2/foo/controller.php b/tests/controller/ext/vendor2/foo/controller.php new file mode 100644 index 0000000000..ce2233b3c9 --- /dev/null +++ b/tests/controller/ext/vendor2/foo/controller.php @@ -0,0 +1,18 @@ +<?php + +namespace foo; + +use Symfony\Component\HttpFoundation\Response; + +class controller +{ +	/** +	* Handle method +	* +	* @return null +	*/ +	public function handle() +	{ +		return new Response('Test', 200); +	} +} diff --git a/tests/controller/ext/vendor2/foo/subfolder/config/routing.yml b/tests/controller/ext/vendor2/foo/subfolder/config/routing.yml new file mode 100644 index 0000000000..20810a8f25 --- /dev/null +++ b/tests/controller/ext/vendor2/foo/subfolder/config/routing.yml @@ -0,0 +1,3 @@ +controller_noroute: +    path: /donotfindthis +    defaults: { _controller: foo.controller:handle } 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..f27ac81b04 --- /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__) . '/common_helper_route.php'; + +class phpbb_controller_helper_route_adm_subdir_test extends phpbb_controller_common_helper_route +{ +	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 new file mode 100644 index 0000000000..86dc36ef1f --- /dev/null +++ b/tests/controller/helper_route_adm_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__) . '/common_helper_route.php'; + +class phpbb_controller_helper_route_adm_test extends phpbb_controller_common_helper_route +{ +	protected function get_phpbb_root_path() +	{ +		return './../'; +	} + +	protected function get_uri() +	{ +		return '/adm/index.php'; +	} + +	protected function get_script_name() +	{ +		return 'index.php'; +	} +} diff --git a/tests/controller/helper_route_other_app.php b/tests/controller/helper_route_other_app.php new file mode 100644 index 0000000000..e5513a5180 --- /dev/null +++ b/tests/controller/helper_route_other_app.php @@ -0,0 +1,37 @@ +<?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__) . '/common_helper_route.php'; + +class phpbb_controller_helper_route_other_app_test extends phpbb_controller_common_helper_route +{ +	protected function get_phpbb_root_path() +	{ +		return './../'; +	} + +	protected function get_uri() +	{ +		return '/foo/app.php'; +	} + +	protected function get_script_name() +	{ +		return 'app.php'; +	} + +	protected function path_to_app() +	{ +		return 'foo/'; +	} +} diff --git a/tests/controller/helper_route_root_test.php b/tests/controller/helper_route_root_test.php new file mode 100644 index 0000000000..63a2f2f8f7 --- /dev/null +++ b/tests/controller/helper_route_root_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__) . '/common_helper_route.php'; + +class phpbb_controller_helper_route_test extends phpbb_controller_common_helper_route +{ +	protected function get_phpbb_root_path() +	{ +		return ''; +	} + +	protected function get_uri() +	{ +		return '/app.php'; +	} + +	protected function get_script_name() +	{ +		return 'app.php'; +	} +} diff --git a/tests/controller/helper_route_slash_test.php b/tests/controller/helper_route_slash_test.php new file mode 100644 index 0000000000..3db5ec19e5 --- /dev/null +++ b/tests/controller/helper_route_slash_test.php @@ -0,0 +1,43 @@ +<?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__) . '/common_helper_route.php'; + +class phpbb_controller_helper_route_slash_test extends phpbb_controller_common_helper_route +{ +	protected function get_phpbb_root_path() +	{ +		return './../'; +	} + +	protected function get_uri() +	{ +		return '/phpBB3/app.php'; +	} + +	protected function get_base_uri() +	{ +		return '/phpBB3/'; +	} + +	protected function get_script_name() +	{ +		return 'app.php'; +	} + +	protected function path_to_app() +	{ +		return 'phpBB3/'; +	} +} 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..9d8b62bc1c --- /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__) . '/common_helper_route.php'; + +class phpbb_controller_helper_route_unclean_path_test extends phpbb_controller_common_helper_route +{ +	protected function get_phpbb_root_path() +	{ +		return './../'; +	} + +	protected function get_uri() +	{ +		return '/adm/../bertie/index.php'; +	} + +	protected function get_script_name() +	{ +		return 'index.php'; +	} +} diff --git a/tests/controller/phpbb/controller/foo.php b/tests/controller/phpbb/controller/foo.php new file mode 100644 index 0000000000..98669f428f --- /dev/null +++ b/tests/controller/phpbb/controller/foo.php @@ -0,0 +1,18 @@ +<?php + +namespace phpbb\controller; + +use Symfony\Component\HttpFoundation\Response; + +class foo +{ +	/** +	* Bar method +	* +	* @return null +	*/ +	public function bar() +	{ +		return new Response('bar()', 200); +	} +} | 
