Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
63.80% covered (warning)
63.80%
289 / 453
50.00% covered (danger)
50.00%
13 / 26
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_controller_common_helper_route
63.80% covered (warning)
63.80%
289 / 453
50.00% covered (danger)
50.00%
13 / 26
58.08
0.00% covered (danger)
0.00%
0 / 1
 getDataSet
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setUp
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
 get_phpbb_root_path
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_uri
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_base_uri
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_script_name
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 path_to_app
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 generate_route_objects
100.00% covered (success)
100.00%
69 / 69
100.00% covered (success)
100.00%
1 / 1
1
 helper_url_data_no_rewrite
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
2
 test_helper_url_no_rewrite
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
 helper_url_data_with_rewrite
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
2
 test_helper_url_with_rewrite
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
 helper_url_data_absolute
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
2
 test_helper_url_absolute
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
 helper_url_data_relative_path
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
2
 test_helper_url_relative_path
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
 helper_url_data_network
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
2
 test_helper_url_network
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
 helper_url_data_absolute_with_rewrite
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
2
 test_helper_url_absolute_with_rewrite
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
 helper_url_data_relative_path_with_rewrite
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 1
2
 test_helper_url_relative_path_with_rewrite
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
 helper_url_data_network_with_rewrite
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 1
2
 test_helper_url_network_with_rewrite
100.00% covered (success)
100.00%
22 / 22
100.00% covered (success)
100.00%
1 / 1
1
 helper_url_data_force_server_vars
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 test_helper_url_force_server_vars
100.00% covered (success)
100.00%
29 / 29
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
15
16abstract class phpbb_controller_common_helper_route extends phpbb_database_test_case
17{
18    protected    $root_path;
19    private        $auth;
20    private        $cache;
21    private        $db;
22    private        $dispatcher;
23    private        $language;
24    private        $admin_path;
25    private        $php_ext;
26    private        $user;
27    private        $config;
28    private        $template;
29    private        $extension_manager;
30    private        $request;
31    private        $symfony_request;
32    private        $provider;
33    private        $filesystem;
34    private        $phpbb_path_helper;
35    private        $helper;
36    private        $router;
37    private        $routing_helper;
38
39    public function getDataSet()
40    {
41        return $this->createXMLDataSet(__DIR__ . '/../fixtures/empty.xml');
42    }
43
44    protected function setUp(): void
45    {
46        global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
47
48        $this->extension_manager = new phpbb_mock_extension_manager(
49            __DIR__ . '/',
50            array(
51                'vendor2/foo' => array(
52                    'ext_name' => 'vendor2/foo',
53                    'ext_active' => '1',
54                    'ext_path' => 'ext/vendor2/foo/',
55                ),
56            )
57        );
58        $this->generate_route_objects();
59        $phpbb_dispatcher = new phpbb_mock_event_dispatcher;
60    }
61
62    protected function get_phpbb_root_path()
63    {
64        return '';
65    }
66
67    protected function get_uri()
68    {
69        return '/app.php';
70    }
71
72    protected function get_base_uri()
73    {
74        return $this->get_uri();
75    }
76
77    protected function get_script_name()
78    {
79        return 'app.php';
80    }
81
82    protected static function path_to_app()
83    {
84        return '';
85    }
86
87    protected function generate_route_objects()
88    {
89        global $request, $phpbb_root_path, $phpEx;
90
91        $this->request = new phpbb_mock_request();
92        $this->request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER);
93        $this->request->overwrite('SCRIPT_FILENAME', $this->get_script_name(), \phpbb\request\request_interface::SERVER);
94        $this->request->overwrite('REQUEST_URI', $this->get_base_uri(), \phpbb\request\request_interface::SERVER);
95        $this->request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER);
96        $this->request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER);
97
98        $request = $this->request;
99
100        $this->symfony_request = new \phpbb\symfony_request(
101            $this->request
102        );
103        $this->filesystem = new \phpbb\filesystem\filesystem();
104        $this->phpbb_path_helper = new \phpbb\path_helper(
105            $this->symfony_request,
106            $this->request,
107            $phpbb_root_path,
108            $phpEx
109        );
110
111        $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
112        $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
113        $lang = new \phpbb\language\language($lang_loader);
114        $this->user = new \phpbb\user($lang, '\phpbb\datetime');
115
116        $container = new phpbb_mock_container_builder();
117        $container->setParameter('core.environment', PHPBB_ENVIRONMENT);
118        $cache_path = $phpbb_root_path . 'cache/twig';
119        $assets_bag = new \phpbb\template\assets_bag();
120        $context = new \phpbb\template\context();
121        $loader = new \phpbb\template\twig\loader('');
122        $twig = new \phpbb\template\twig\environment(
123            $assets_bag,
124            $this->config,
125            $this->filesystem,
126            $this->phpbb_path_helper,
127            $cache_path,
128            null,
129            $loader,
130            new \phpbb\event\dispatcher(),
131            array(
132                'cache'            => false,
133                'debug'            => false,
134                'auto_reload'    => true,
135                'autoescape'    => false,
136            )
137        );
138        $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
139        $twig->setLexer(new \phpbb\template\twig\lexer($twig));
140
141        $this->extension_manager = new phpbb_mock_extension_manager(
142            __DIR__ . '/',
143            array(
144                'vendor2/foo' => array(
145                    'ext_name' => 'vendor2/foo',
146                    'ext_active' => '1',
147                    'ext_path' => 'ext/vendor2/foo/',
148                ),
149            )
150        );
151
152        $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader(
153            new \phpbb\routing\file_locator(__DIR__ . '/')
154        );
155        $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(__DIR__ . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
156        $this->router = new phpbb_mock_router($container, $resources_locator, $loader, 'php', __DIR__ . '/', true, true);
157        $this->auth = new \phpbb\auth\auth();
158        $this->cache = new \phpbb\cache\driver\dummy();
159        $this->db = $this->new_dbal();
160        $this->dispatcher = new phpbb_mock_event_dispatcher();
161        $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
162        $this->admin_path = 'adm/';
163        $this->php_ext = $phpEx;
164
165        // Set correct current phpBB root path
166        $this->root_path = $this->get_phpbb_root_path();
167    }
168
169    public static function helper_url_data_no_rewrite()
170    {
171        return array(
172            array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
173            array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
174            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
175            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
176
177            // Custom sid parameter
178            array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
179            array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
180            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
181
182            // Testing anchors
183            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
184            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
185            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
186
187            // Anchors and custom sid
188            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
189            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
190            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
191
192            // Empty parameters should not append the &amp; or ?
193            array('controller2', array(), true, false, '/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
194            array('controller2', array(), false, false, '/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
195            array('controller3', array('p' => 3), true, false, '/' . static::path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
196
197            // Resolves DI parameters
198            array('controller4', array(), true, false, '/' . static::path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
199        );
200    }
201
202    /**
203    * @dataProvider helper_url_data_no_rewrite()
204    */
205    public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
206    {
207        $mock_container = new phpbb_mock_container_builder();
208        $mock_container->set('cron.task_collection', []);
209
210        $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
211        $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
212        $this->helper = new phpbb_mock_controller_helper(
213            $this->auth,
214            $this->cache,
215            $this->config,
216            new \phpbb\cron\manager($mock_container, $this->routing_helper, $this->root_path, 'php', null),
217            $this->db,
218            $this->dispatcher,
219            $this->language,
220            $this->request,
221            $this->routing_helper,
222            $this->symfony_request,
223            $this->template,
224            $this->user,
225            $this->root_path,
226            $this->admin_path,
227            $this->php_ext
228        );
229        static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
230    }
231
232    public static function helper_url_data_with_rewrite()
233    {
234        return array(
235            array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
236            array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . static::path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
237            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
238            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
239
240            // Custom sid parameter
241            array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
242            array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
243            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
244
245            // Testing anchors
246            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
247            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . static::path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
248            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
249
250            // Anchors and custom sid
251            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
252            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
253            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
254
255            // Empty parameters should not append the &amp; or ?
256            array('controller2', array(), true, false, '/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
257            array('controller2', array(), false, false, '/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
258            array('controller3', array('p' => 3), true, false, '/' . static::path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
259
260            // Resolves DI parameters
261            array('controller4', array(), true, false, '/' . static::path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
262        );
263    }
264
265    /**
266    * @dataProvider helper_url_data_with_rewrite()
267    */
268    public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
269    {
270        $mock_container = new phpbb_mock_container_builder();
271        $mock_container->set('cron.task_collection', []);
272
273        $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
274        $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
275        $this->helper = new phpbb_mock_controller_helper(
276            $this->auth,
277            $this->cache,
278            $this->config,
279            new \phpbb\cron\manager($mock_container, $this->routing_helper, $this->root_path, 'php', null),
280            $this->db,
281            $this->dispatcher,
282            $this->language,
283            $this->request,
284            $this->routing_helper,
285            $this->symfony_request,
286            $this->template,
287            $this->user,
288            $this->root_path,
289            $this->admin_path,
290            $this->php_ext
291        );
292        static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
293    }
294
295    public static function helper_url_data_absolute()
296    {
297        return array(
298            array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
299            array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
300            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
301            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
302
303            // Custom sid parameter
304            array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
305            array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
306            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
307
308            // Testing anchors
309            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
310            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
311            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
312
313            // Anchors and custom sid
314            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
315            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
316            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
317
318            // Empty parameters should not append the &amp; or ?
319            array('controller2', array(), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
320            array('controller2', array(), false, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
321            array('controller3', array('p' => 3), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
322
323            // Resolves DI parameters
324            array('controller4', array(), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
325        );
326    }
327
328    /**
329    * @dataProvider helper_url_data_absolute()
330    */
331    public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description)
332    {
333        $mock_container = new phpbb_mock_container_builder();
334        $mock_container->set('cron.task_collection', []);
335
336        $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
337        $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
338        $this->helper = new phpbb_mock_controller_helper(
339            $this->auth,
340            $this->cache,
341            $this->config,
342            new \phpbb\cron\manager($mock_container, $this->routing_helper, $this->root_path, 'php', null),
343            $this->db,
344            $this->dispatcher,
345            $this->language,
346            $this->request,
347            $this->routing_helper,
348            $this->symfony_request,
349            $this->template,
350            $this->user,
351            $this->root_path,
352            $this->admin_path,
353            $this->php_ext
354        );
355        static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
356    }
357
358    public static function helper_url_data_relative_path()
359    {
360        return array(
361            array('controller2', array('t' => 1, 'f' => 2), true, false, 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
362            array('controller2', array('t' => 1, 'f' => 2), false, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
363            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
364            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'),
365
366            // Custom sid parameter
367            array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
368            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'),
369            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
370
371            // Testing anchors
372            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
373            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
374            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
375
376            // Anchors and custom sid
377            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
378            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'),
379            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
380
381            // Empty parameters should not append the &amp; or ?
382            array('controller2', array(), true, false, 'app.php/foo/bar', 'no params using empty array'),
383            array('controller2', array(), false, false, 'app.php/foo/bar', 'no params using empty array'),
384            array('controller3', array('p' => 3), true, false, 'app.php/foo/bar/p-3', 'no params using empty array'),
385
386            // Resolves DI parameters
387            array('controller4', array(), true, false,  'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
388        );
389    }
390
391    /**
392    * @dataProvider helper_url_data_relative_path()
393    */
394    public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description)
395    {
396        $mock_container = new phpbb_mock_container_builder();
397        $mock_container->set('cron.task_collection', []);
398
399        $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
400        $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
401        $this->helper = new phpbb_mock_controller_helper(
402            $this->auth,
403            $this->cache,
404            $this->config,
405            new \phpbb\cron\manager($mock_container, $this->routing_helper, $this->root_path, 'php', null),
406            $this->db,
407            $this->dispatcher,
408            $this->language,
409            $this->request,
410            $this->routing_helper,
411            $this->symfony_request,
412            $this->template,
413            $this->user,
414            $this->root_path,
415            $this->admin_path,
416            $this->php_ext
417        );
418        static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
419    }
420
421    public static function helper_url_data_network()
422    {
423        return array(
424            array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
425            array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
426            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
427            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
428
429            // Custom sid parameter
430            array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
431            array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
432            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
433
434            // Testing anchors
435            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
436            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
437            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
438
439            // Anchors and custom sid
440            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
441            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
442            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
443
444            // Empty parameters should not append the &amp; or ?
445            array('controller2', array(), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
446            array('controller2', array(), false, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
447            array('controller3', array('p' => 3), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
448
449            // Resolves DI parameters
450            array('controller4', array(), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
451        );
452    }
453
454    /**
455    * @dataProvider helper_url_data_network()
456    */
457    public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description)
458    {
459        $mock_container = new phpbb_mock_container_builder();
460        $mock_container->set('cron.task_collection', []);
461
462        $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
463        $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
464        $this->helper = new phpbb_mock_controller_helper(
465            $this->auth,
466            $this->cache,
467            $this->config,
468            new \phpbb\cron\manager($mock_container, $this->routing_helper, $this->root_path, 'php', null),
469            $this->db,
470            $this->dispatcher,
471            $this->language,
472            $this->request,
473            $this->routing_helper,
474            $this->symfony_request,
475            $this->template,
476            $this->user,
477            $this->root_path,
478            $this->admin_path,
479            $this->php_ext
480        );
481        static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
482    }
483
484    public static function helper_url_data_absolute_with_rewrite()
485    {
486        return array(
487            array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
488            array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
489            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
490            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
491
492            // Custom sid parameter
493            array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
494            array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
495            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
496
497            // Testing anchors
498            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
499            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
500            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
501
502            // Anchors and custom sid
503            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
504            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
505            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
506
507            // Empty parameters should not append the &amp; or ?
508            array('controller2', array(), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
509            array('controller2', array(), false, false, 'http://localhost/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
510            array('controller3', array('p' => 3), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
511
512            // Resolves DI parameters
513            array('controller4', array(), true, false, 'http://localhost/' . static::path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
514        );
515    }
516
517    /**
518     * @dataProvider helper_url_data_absolute_with_rewrite()
519     */
520    public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
521    {
522        $mock_container = new phpbb_mock_container_builder();
523        $mock_container->set('cron.task_collection', []);
524
525        $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
526        $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
527        $this->helper = new phpbb_mock_controller_helper(
528            $this->auth,
529            $this->cache,
530            $this->config,
531            new \phpbb\cron\manager($mock_container, $this->routing_helper, $this->root_path, 'php', null),
532            $this->db,
533            $this->dispatcher,
534            $this->language,
535            $this->request,
536            $this->routing_helper,
537            $this->symfony_request,
538            $this->template,
539            $this->user,
540            $this->root_path,
541            $this->admin_path,
542            $this->php_ext
543        );
544        static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
545    }
546
547    public static function helper_url_data_relative_path_with_rewrite()
548    {
549        return array(
550            array('controller2', array('t' => 1, 'f' => 2), true, false, 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
551            array('controller2', array('t' => 1, 'f' => 2), false, false, 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
552            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
553            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'),
554
555            // Custom sid parameter
556            array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
557            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'),
558            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
559
560            // Testing anchors
561            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
562            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
563            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
564
565            // Anchors and custom sid
566            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
567            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'),
568            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
569
570            // Empty parameters should not append the &amp; or ?
571            array('controller2', array(), true, false, 'foo/bar', 'no params using empty array'),
572            array('controller2', array(), false, false, 'foo/bar', 'no params using empty array'),
573            array('controller3', array('p' => 3), true, false, 'foo/bar/p-3', 'no params using empty array'),
574        );
575    }
576
577    /**
578     * @dataProvider helper_url_data_relative_path_with_rewrite()
579     */
580    public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
581    {
582        $mock_container = new phpbb_mock_container_builder();
583        $mock_container->set('cron.task_collection', []);
584
585        $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
586        $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
587        $this->helper = new phpbb_mock_controller_helper(
588            $this->auth,
589            $this->cache,
590            $this->config,
591            new \phpbb\cron\manager($mock_container, $this->routing_helper, $this->root_path, 'php', null),
592            $this->db,
593            $this->dispatcher,
594            $this->language,
595            $this->request,
596            $this->routing_helper,
597            $this->symfony_request,
598            $this->template,
599            $this->user,
600            $this->root_path,
601            $this->admin_path,
602            $this->php_ext
603        );
604        static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
605    }
606
607    public static function helper_url_data_network_with_rewrite()
608    {
609        return array(
610            array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
611            array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
612            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
613            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
614
615            // Custom sid parameter
616            array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
617            array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
618            array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
619
620            // Testing anchors
621            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
622            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
623            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
624
625            // Anchors and custom sid
626            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
627            array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
628            array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
629
630            // Empty parameters should not append the &amp; or ?
631            array('controller2', array(), true, false, '//localhost/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
632            array('controller2', array(), false, false, '//localhost/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
633            array('controller3', array('p' => 3), true, false, '//localhost/' . static::path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
634
635            // Resolves DI parameters
636            array('controller4', array(), true, false, '//localhost/' . static::path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
637        );
638    }
639
640    /**
641     * @dataProvider helper_url_data_network_with_rewrite()
642     */
643    public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
644    {
645        $mock_container = new phpbb_mock_container_builder();
646        $mock_container->set('cron.task_collection', []);
647
648        $this->config = new \phpbb\config\config(['enable_mod_rewrite' => '1']);
649        $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
650        $this->helper = new phpbb_mock_controller_helper(
651            $this->auth,
652            $this->cache,
653            $this->config,
654            new \phpbb\cron\manager($mock_container, $this->routing_helper, $this->root_path, 'php', null),
655            $this->db,
656            $this->dispatcher,
657            $this->language,
658            $this->request,
659            $this->routing_helper,
660            $this->symfony_request,
661            $this->template,
662            $this->user,
663            $this->root_path,
664            $this->admin_path,
665            $this->php_ext
666        );
667        static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
668    }
669
670    public static function helper_url_data_force_server_vars()
671    {
672        return array(
673            array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/app.php/foo'),
674            array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::ABSOLUTE_URL, 'https://my_server:444/my/board/foo'),
675            array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/my/board/app.php/foo'),
676            array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:444/my/board/foo'),
677            array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/app.php/foo'),
678            array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/foo'),
679            array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'app.php/foo'),
680            array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'foo'),        );
681    }
682
683    /**
684     * @dataProvider helper_url_data_force_server_vars()
685     */
686    public function test_helper_url_force_server_vars($enable_mod_rewrite, $force_server_vars, $server_name, $server_port, $script_path, $server_protocol, $type, $expected)
687    {
688        $this->config = new \phpbb\config\config(array(
689            'enable_mod_rewrite' => $enable_mod_rewrite,
690            'force_server_vars' => $force_server_vars,
691            'server_name' => $server_name,
692            'server_port' => $server_port,
693            'script_path' => $script_path,
694            'server_protocol' => $server_protocol,
695        ));
696
697        $mock_container = new phpbb_mock_container_builder();
698        $mock_container->set('cron.task_collection', []);
699
700        $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php');
701
702        $this->helper = new phpbb_mock_controller_helper(
703            $this->auth,
704            $this->cache,
705            $this->config,
706            new \phpbb\cron\manager($mock_container, $this->routing_helper, $this->root_path, 'php', null),
707            $this->db,
708            $this->dispatcher,
709            $this->language,
710            $this->request,
711            $this->routing_helper,
712            $this->symfony_request,
713            $this->template,
714            $this->user,
715            $this->root_path,
716            $this->admin_path,
717            $this->php_ext
718        );
719        static::assertEquals($expected, $this->helper->route('controller1', array(), false, false, $type));
720    }
721}