diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/console/user/activate_test.php | 86 | ||||
-rw-r--r-- | tests/console/user/add_test.php | 121 | ||||
-rw-r--r-- | tests/console/user/base.php | 121 | ||||
-rw-r--r-- | tests/console/user/delete_test.php | 93 | ||||
-rw-r--r-- | tests/console/user/fixtures/config.xml | 20 | ||||
-rw-r--r-- | tests/console/user/reclean_test.php | 49 | ||||
-rw-r--r-- | tests/controller/common_helper_route.php | 66 |
7 files changed, 441 insertions, 115 deletions
diff --git a/tests/console/user/activate_test.php b/tests/console/user/activate_test.php new file mode 100644 index 0000000000..1588a76e47 --- /dev/null +++ b/tests/console/user/activate_test.php @@ -0,0 +1,86 @@ +<?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. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use phpbb\console\command\user\activate; + +require_once dirname(__FILE__) . '/base.php'; + +class phpbb_console_user_activate_test extends phpbb_console_user_base +{ + protected $notifications; + + public function setUp() + { + parent::setUp(); + + $this->notifications = $this->getMockBuilder('\phpbb\notification\manager') + ->disableOriginalConstructor() + ->getMock(); + } + + public function get_command_tester() + { + $application = new Application(); + $application->add(new activate( + $this->user, + $this->db, + $this->config, + $this->language, + $this->log, + $this->notifications, + $this->user_loader, + $this->phpbb_root_path, + $this->php_ext + )); + + $command = $application->find('user:activate'); + $this->command_name = $command->getName(); + + return new CommandTester($command); + } + + public function activate_test_data() + { + return array( + // Test an inactive user + array('Test', false, 'USER_ADMIN_ACTIVATED'), + array('Test', true, 'CLI_DESCRIPTION_USER_ACTIVATE_INACTIVE'), + + // Test an active user + array('Test 2', false, 'CLI_DESCRIPTION_USER_ACTIVATE_ACTIVE'), + array('Test 2', true, 'USER_ADMIN_DEACTIVED'), + + // Test a non existent user + array('Foo', false, 'NO_USER'), + array('Foo', true, 'NO_USER'), + ); + } + + /** + * @dataProvider activate_test_data + */ + public function test_activate($username, $deactivate, $expected) + { + $command_tester = $this->get_command_tester(); + + $command_tester->execute(array( + 'command' => $this->command_name, + 'username' => $username, + '--deactivate' => $deactivate, + )); + + $this->assertContains($expected, $command_tester->getDisplay()); + } +} diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index ee6eee8491..8641bf87b6 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -15,75 +15,27 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use phpbb\console\command\user\add; -require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_user.php'; +require_once dirname(__FILE__) . '/base.php'; -class phpbb_console_command_user_add_test extends phpbb_database_test_case +class phpbb_console_user_add_test extends phpbb_console_user_base { - protected $db; - protected $config; - protected $user; - protected $language; - protected $passwords_manager; - protected $command_name; - protected $question; - protected $phpbb_root_path; - protected $php_ext; - - public function getDataSet() - { - return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); - } - - public function setUp() + public function get_command_tester() { - global $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; - - $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $phpbb_container = new phpbb_mock_container_builder(); - $phpbb_container->set('cache.driver', new phpbb_mock_cache()); - $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - - $cache = $phpbb_container->get('cache.driver'); - - $config = $this->config = new \phpbb\config\config(array( - 'board_timezone' => 'UTC', - 'default_lang' => 'en', - 'email_enable' => false, - 'min_name_chars' => 3, - 'max_name_chars' => 10, - 'min_pass_chars' => 3, - 'max_pass_chars' => 10, - 'pass_complex' => 'PASS_TYPE_ANY', - )); - - $db = $this->db = $this->new_dbal(); - - $this->language = $this->getMockBuilder('\phpbb\language\language') - ->disableOriginalConstructor() - ->getMock(); - $this->language->expects($this->any()) - ->method('lang') - ->will($this->returnArgument(0)); - $user = $this->user = $this->getMock('\phpbb\user', array(), array( + $application = new Application(); + $application->add(new add( + $this->user, + $this->db, + $this->config, $this->language, - '\phpbb\datetime' + $this->passwords_manager, + $this->phpbb_root_path, + $this->php_ext )); - $driver_helper = new \phpbb\passwords\driver\helper($this->config); - $passwords_drivers = array( - 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($this->config, $driver_helper), - 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($this->config, $driver_helper), - 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($this->config, $driver_helper), - 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($this->config, $driver_helper), - ); - - $passwords_helper = new \phpbb\passwords\helper; - $this->passwords_manager = new \phpbb\passwords\manager($this->config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); - - $this->phpbb_root_path = $phpbb_root_path; - $this->php_ext = $phpEx; - - parent::setUp(); + $command = $application->find('user:add'); + $this->command_name = $command->getName(); + $this->question = $command->getHelper('question'); + return new CommandTester($command); } public function test_add_no_dialog() @@ -137,47 +89,4 @@ class phpbb_console_command_user_add_test extends phpbb_database_test_case $this->assertContains('TOO_SHORT', $command_tester->getDisplay()); $this->assertContains('EMAIL_INVALID', $command_tester->getDisplay()); } - - public function get_command_tester() - { - $application = new Application(); - $application->add(new add( - $this->user, - $this->db, - $this->config, - $this->language, - $this->passwords_manager, - $this->phpbb_root_path, - $this->php_ext - )); - - $command = $application->find('user:add'); - $this->command_name = $command->getName(); - $this->question = $command->getHelper('question'); - return new CommandTester($command); - } - - public function get_user_id($username) - { - $sql = 'SELECT user_id - FROM ' . USERS_TABLE . ' - WHERE ' . 'username = ' . "'" . $username . "'"; - - $result = $this->db->sql_query($sql); - - $row = $this->db->sql_fetchrow($result); - - $this->db->sql_freeresult($result); - - return $row['user_id']; - } - - public function getInputStream($input) - { - $stream = fopen('php://memory', 'r+', false); - fputs($stream, $input); - rewind($stream); - - return $stream; - } } diff --git a/tests/console/user/base.php b/tests/console/user/base.php new file mode 100644 index 0000000000..b84c0bb267 --- /dev/null +++ b/tests/console/user/base.php @@ -0,0 +1,121 @@ +<?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. +* +*/ + +abstract class phpbb_console_user_base extends phpbb_database_test_case +{ + protected $db; + protected $config; + protected $user; + protected $language; + protected $log; + protected $passwords_manager; + protected $command_name; + protected $question; + protected $user_loader; + protected $phpbb_root_path; + protected $php_ext; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + public function setUp() + { + global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->set('cache.driver', new phpbb_mock_cache()); + $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + + $auth = $this->getMock('\phpbb\auth\auth'); + + $cache = $phpbb_container->get('cache.driver'); + + $config = $this->config = new \phpbb\config\config(array( + 'board_timezone' => 'UTC', + 'default_lang' => 'en', + 'email_enable' => false, + 'min_name_chars' => 3, + 'max_name_chars' => 10, + 'min_pass_chars' => 3, + 'max_pass_chars' => 10, + 'pass_complex' => 'PASS_TYPE_ANY', + )); + + $db = $this->db = $this->new_dbal(); + + $this->language = $this->getMockBuilder('\phpbb\language\language') + ->disableOriginalConstructor() + ->getMock(); + $this->language->expects($this->any()) + ->method('lang') + ->will($this->returnArgument(0)); + $user = $this->user = $this->getMock('\phpbb\user', array(), array( + $this->language, + '\phpbb\datetime' + )); + + $this->user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE); + + $driver_helper = new \phpbb\passwords\driver\helper($this->config); + $passwords_drivers = array( + 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($this->config, $driver_helper), + 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($this->config, $driver_helper), + 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($this->config, $driver_helper), + 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($this->config, $driver_helper), + ); + + $passwords_helper = new \phpbb\passwords\helper; + $this->passwords_manager = new \phpbb\passwords\manager($this->config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers)); + + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $phpEx; + + $this->log = $this->getMockBuilder('\phpbb\log\log') + ->disableOriginalConstructor() + ->getMock(); + + $phpbb_container->set('auth.provider.db', new phpbb_mock_auth_provider()); + $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); + $provider_collection->add('auth.provider.db'); + $phpbb_container->set( + 'auth.provider_collection', + $provider_collection + ); + + parent::setUp(); + } + + public function get_user_id($username) + { + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . ' + WHERE ' . 'username = ' . "'" . $username . "'"; + $result = $this->db->sql_query($sql); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + return $row['user_id']; + } + + public function getInputStream($input) + { + $stream = fopen('php://memory', 'r+', false); + fputs($stream, $input); + rewind($stream); + + return $stream; + } +} diff --git a/tests/console/user/delete_test.php b/tests/console/user/delete_test.php new file mode 100644 index 0000000000..88f91afab1 --- /dev/null +++ b/tests/console/user/delete_test.php @@ -0,0 +1,93 @@ +<?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. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use phpbb\console\command\user\delete; + +require_once dirname(__FILE__) . '/base.php'; + +class phpbb_console_user_delete_test extends phpbb_console_user_base +{ + public function get_command_tester() + { + $application = new Application(); + $application->add(new delete( + $this->user, + $this->db, + $this->language, + $this->log, + $this->user_loader, + $this->phpbb_root_path, + $this->php_ext + )); + + $command = $application->find('user:delete'); + $this->command_name = $command->getName(); + $this->question = $command->getHelper('question'); + + return new CommandTester($command); + } + + public function test_delete() + { + $command_tester = $this->get_command_tester(); + + $this->assertEquals(3, $this->get_user_id('Test')); + + $this->question->setInputStream($this->getInputStream("yes\n")); + + $command_tester->execute(array( + 'command' => $this->command_name, + 'username' => 'Test', + '--delete-posts' => false, + )); + + $this->assertNull($this->get_user_id('Test')); + $this->assertContains('USER_DELETED', $command_tester->getDisplay()); + } + + public function test_delete_non_user() + { + $command_tester = $this->get_command_tester(); + + $this->assertNull($this->get_user_id('Foo')); + + $this->question->setInputStream($this->getInputStream("yes\n")); + + $command_tester->execute(array( + 'command' => $this->command_name, + 'username' => 'Foo', + '--delete-posts' => false, + )); + + $this->assertContains('NO_USER', $command_tester->getDisplay()); + } + + public function test_delete_cancel() + { + $command_tester = $this->get_command_tester(); + + $this->assertEquals(3, $this->get_user_id('Test')); + + $this->question->setInputStream($this->getInputStream("no\n")); + + $command_tester->execute(array( + 'command' => $this->command_name, + 'username' => 'Test', + '--delete-posts' => false, + )); + + $this->assertNotNull($this->get_user_id('Test')); + } +} diff --git a/tests/console/user/fixtures/config.xml b/tests/console/user/fixtures/config.xml index fed30dc20d..a988ba463f 100644 --- a/tests/console/user/fixtures/config.xml +++ b/tests/console/user/fixtures/config.xml @@ -6,12 +6,14 @@ <column>username</column> <column>username_clean</column> <column>user_sig</column> + <column>user_type</column> <row> <value>1</value> <value></value> <value>Guest</value> <value>guest</value> <value></value> + <value>0</value> </row> <row> <value>2</value> @@ -19,6 +21,7 @@ <value>Admin</value> <value>admin</value> <value></value> + <value>3</value> </row> <row> <value>3</value> @@ -26,6 +29,23 @@ <value>Test</value> <value>test</value> <value></value> + <value>1</value> + </row> + <row> + <value>4</value> + <value></value> + <value>Test 2</value> + <value>test 2</value> + <value></value> + <value>0</value> + </row> + <row> + <value>5</value> + <value></value> + <value>Test Unclean</value> + <value>Test Unclean</value> + <value></value> + <value>0</value> </row> </table> <table name="phpbb_groups"> diff --git a/tests/console/user/reclean_test.php b/tests/console/user/reclean_test.php new file mode 100644 index 0000000000..1bf0b8ef5a --- /dev/null +++ b/tests/console/user/reclean_test.php @@ -0,0 +1,49 @@ +<?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. +* +*/ + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; +use phpbb\console\command\user\reclean; + +require_once dirname(__FILE__) . '/base.php'; + +class phpbb_console_user_reclean_test extends phpbb_console_user_base +{ + public function get_command_tester() + { + $application = new Application(); + $application->add(new reclean( + $this->user, + $this->db, + $this->language + )); + + $command = $application->find('user:reclean'); + $this->command_name = $command->getName(); + + return new CommandTester($command); + } + + public function test_reclean() + { + $command_tester = $this->get_command_tester(); + + $exit_status = $command_tester->execute(array('command' => $this->command_name)); + $this->assertSame(0, $exit_status); + + $result = $this->db->sql_query('SELECT user_id FROM ' . USERS_TABLE . " WHERE username_clean = 'test unclean'"); + $row = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + $this->assertNotNull($row['user_id']); + } +} diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 21397d0f77..367c15a667 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -16,6 +16,18 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; abstract class phpbb_controller_common_helper_route extends phpbb_test_case { protected $root_path; + private $user; + private $config; + private $template; + private $extension_manager; + private $request; + private $symfony_request; + private $provider; + private $filesystem; + private $phpbb_path_helper; + private $helper; + private $router; + private $routing_helper; public function setUp() { @@ -62,6 +74,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case protected function generate_route_objects() { + global $request; + $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); @@ -69,6 +83,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER); $this->request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER); + $request = $this->request; + $this->symfony_request = new \phpbb\symfony_request( $this->request ); @@ -170,7 +186,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); + static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); } public function helper_url_data_with_rewrite() @@ -214,7 +230,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); + static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); } public function helper_url_data_absolute() @@ -258,7 +274,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); + static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); } public function helper_url_data_relative_path() @@ -302,7 +318,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); + static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); } public function helper_url_data_network() @@ -346,7 +362,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); + static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); } public function helper_url_data_absolute_with_rewrite() @@ -390,7 +406,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); + static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); } public function helper_url_data_relative_path_with_rewrite() @@ -431,7 +447,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); + static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); } public function helper_url_data_network_with_rewrite() @@ -472,9 +488,41 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case */ 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->config = new \phpbb\config\config(['enable_mod_rewrite' => '1']); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); + static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); + } + + public function helper_url_data_force_server_vars() + { + return array( + array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/app.php/foo'), + array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::ABSOLUTE_URL, 'https://my_server:444/my/board/foo'), + array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/my/board/app.php/foo'), + array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:444/my/board/foo'), + array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/app.php/foo'), + array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/foo'), + array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'app.php/foo'), + array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'foo'), ); + } + + /** + * @dataProvider helper_url_data_force_server_vars() + */ + public function test_helper_url_force_server_vars($enable_mod_rewrite, $force_server_vars, $server_name, $server_port, $script_path, $server_protocol, $type, $expected) + { + $this->config = new \phpbb\config\config(array( + 'enable_mod_rewrite' => $enable_mod_rewrite, + 'force_server_vars' => $force_server_vars, + 'server_name' => $server_name, + 'server_port' => $server_port, + 'script_path' => $script_path, + 'server_protocol' => $server_protocol, + )); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); - $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); + static::assertEquals($expected, $this->helper->route('controller1', array(), false, false, $type)); } } |