From 192b8e2568f499aa2ead98a24d8dd5541b1f315a Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 2 Aug 2014 19:09:42 +0200 Subject: [ticket/11649] Expose Twig through the container PHPBB3-11649 --- tests/controller/helper_route_test.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'tests/controller') diff --git a/tests/controller/helper_route_test.php b/tests/controller/helper_route_test.php index 206c3a4f0b..8113bd0018 100644 --- a/tests/controller/helper_route_test.php +++ b/tests/controller/helper_route_test.php @@ -31,7 +31,28 @@ class phpbb_controller_helper_route_test extends phpbb_test_case $phpEx ); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, new \phpbb\template\context()); + + $container = new phpbb_mock_container_builder(); + $cache_path = $phpbb_root_path . 'cache/twig'; + $context = new \phpbb\template\context(); + $loader = new \phpbb\template\twig\loader(''); + $twig = new \phpbb\template\twig\environment( + $this->config, + $phpbb_path_helper, + $container, + $cache_path, + null, + $loader, + array( + 'cache' => false, + 'debug' => false, + 'auto_reload' => true, + 'autoescape' => false, + ) + ); + $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', array( -- cgit v1.2.1 From a5bfc76a73a213a388126d0f697ba64f27a4b00d Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 14 Sep 2014 21:18:20 +0200 Subject: [ticket/13063] Introduces a new \phpbb\routing\router class PHPBB3-13063 --- tests/controller/common_helper_route.php | 23 ++++++++++++----------- tests/controller/controller_test.php | 8 ++++---- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 5e15eb3ee1..1234c372fe 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -119,9 +119,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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__) . '/'); + $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php'); + $this->router->find_routing_files($finder); + $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); } @@ -161,7 +161,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case */ 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->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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)); } @@ -201,7 +202,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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)); } @@ -241,7 +242,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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)); } @@ -281,7 +282,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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)); } @@ -321,7 +322,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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 @@ -361,7 +362,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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)); } @@ -401,7 +402,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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)); } @@ -441,7 +442,7 @@ 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->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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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/controller_test.php b/tests/controller/controller_test.php index 62feee3fed..cd90dda751 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -33,11 +33,11 @@ class phpbb_controller_controller_test extends phpbb_test_case )); } - public function test_provider() + public function test_router_find_files() { - $provider = new \phpbb\controller\provider(); - $provider->find_routing_files($this->extension_manager->get_finder()); - $routes = $provider->find(__DIR__)->get_routes(); + $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php'); + $router->find_routing_files($this->extension_manager->get_finder()); + $routes = $router->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')); -- cgit v1.2.1 From fdcd6e81cd4ae530036fd18ad184c0d2423c6949 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 20 Nov 2014 16:37:45 +0100 Subject: [ticket/13063] Fix tests after rebase PHPBB3-13063 --- tests/controller/common_helper_route.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 1234c372fe..028a73d70d 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -162,8 +162,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_no_rewrite($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->router, $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)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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), $description); } public function helper_url_data_with_rewrite() @@ -202,8 +202,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $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)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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), $description); } public function helper_url_data_absolute() @@ -242,8 +242,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $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)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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), $description); } public function helper_url_data_relative_path() @@ -282,8 +282,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $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)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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), $description); } public function helper_url_data_network() @@ -322,8 +322,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $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)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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), $description); } //TODO public function helper_url_data_absolute_with_rewrite() @@ -362,8 +362,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $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)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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), $description); } public function helper_url_data_relative_path_with_rewrite() @@ -402,8 +402,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $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)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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), $description); } public function helper_url_data_network_with_rewrite() @@ -442,7 +442,7 @@ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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)); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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), $description); } } -- cgit v1.2.1 From 7cd0fd83b8047f40edfb69a427b14997801ef25b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 5 Sep 2014 03:03:20 +0200 Subject: [ticket/12620] Fix tests PHPBB3-12620 --- tests/controller/config/production/routing.yml | 3 +++ tests/controller/config/routing.yml | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 tests/controller/config/production/routing.yml delete mode 100644 tests/controller/config/routing.yml (limited to 'tests/controller') diff --git a/tests/controller/config/production/routing.yml b/tests/controller/config/production/routing.yml new file mode 100644 index 0000000000..175b11f130 --- /dev/null +++ b/tests/controller/config/production/routing.yml @@ -0,0 +1,3 @@ +core_controller: + pattern: /core_foo + defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/config/routing.yml b/tests/controller/config/routing.yml deleted file mode 100644 index 175b11f130..0000000000 --- a/tests/controller/config/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -core_controller: - pattern: /core_foo - defaults: { _controller: core_foo.controller:bar } -- cgit v1.2.1 From 014eed385bf761d9e3f0992835f44f58bf055afd Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 5 Sep 2014 16:33:57 +0200 Subject: [ticket/12620] Add support of the environments for the ext routing files PHPBB3-12620 --- tests/controller/common_helper_route.php | 6 ------ tests/controller/controller_test.php | 8 ++++++++ .../ext/vendor2/bar/config/production/routing.yml | 3 +++ tests/controller/ext/vendor2/bar/config/services.yml | 3 +++ tests/controller/ext/vendor2/bar/controller.php | 18 ++++++++++++++++++ 5 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 tests/controller/ext/vendor2/bar/config/production/routing.yml create mode 100644 tests/controller/ext/vendor2/bar/config/services.yml create mode 100644 tests/controller/ext/vendor2/bar/controller.php (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 028a73d70d..5baa846ec3 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -113,12 +113,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $finder = new \phpbb\finder( - new \phpbb\filesystem(), - dirname(__FILE__) . '/', - new phpbb_mock_cache() - ); - $finder->set_extensions(array_keys($this->extension_manager->all_enabled())); $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php'); $this->router->find_routing_files($finder); $this->router->find(dirname(__FILE__) . '/'); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index cd90dda751..637e9685e6 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -30,6 +30,11 @@ class phpbb_controller_controller_test extends phpbb_test_case 'ext_active' => '1', 'ext_path' => 'ext/vendor2/foo/', ), + 'vendor2/bar' => array( + 'ext_name' => 'vendor2/bar', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor2/bar/', + ), )); } @@ -49,6 +54,9 @@ class phpbb_controller_controller_test extends phpbb_test_case $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller2')); $this->assertEquals('/foo/bar', $routes->get('controller2')->getPath()); + $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller3')); + $this->assertEquals('/bar', $routes->get('controller3')->getPath()); + $this->assertNull($routes->get('controller_noroute')); } diff --git a/tests/controller/ext/vendor2/bar/config/production/routing.yml b/tests/controller/ext/vendor2/bar/config/production/routing.yml new file mode 100644 index 0000000000..85c93b453f --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/production/routing.yml @@ -0,0 +1,3 @@ +controller3: + pattern: /bar + defaults: { _controller: bar.controller:handle } diff --git a/tests/controller/ext/vendor2/bar/config/services.yml b/tests/controller/ext/vendor2/bar/config/services.yml new file mode 100644 index 0000000000..05a8a1994d --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/services.yml @@ -0,0 +1,3 @@ +services: + bar.controller: + class: bar\controller diff --git a/tests/controller/ext/vendor2/bar/controller.php b/tests/controller/ext/vendor2/bar/controller.php new file mode 100644 index 0000000000..ad35f5a051 --- /dev/null +++ b/tests/controller/ext/vendor2/bar/controller.php @@ -0,0 +1,18 @@ + Date: Thu, 2 Oct 2014 00:45:22 +0200 Subject: [ticket/12620] Updates test environment (production => development) PHPBB3-12620 --- tests/controller/config/development/routing.yml | 3 +++ tests/controller/config/production/routing.yml | 3 --- tests/controller/ext/vendor2/bar/config/development/routing.yml | 3 +++ tests/controller/ext/vendor2/bar/config/production/routing.yml | 3 --- 4 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 tests/controller/config/development/routing.yml delete mode 100644 tests/controller/config/production/routing.yml create mode 100644 tests/controller/ext/vendor2/bar/config/development/routing.yml delete mode 100644 tests/controller/ext/vendor2/bar/config/production/routing.yml (limited to 'tests/controller') diff --git a/tests/controller/config/development/routing.yml b/tests/controller/config/development/routing.yml new file mode 100644 index 0000000000..175b11f130 --- /dev/null +++ b/tests/controller/config/development/routing.yml @@ -0,0 +1,3 @@ +core_controller: + pattern: /core_foo + defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/config/production/routing.yml b/tests/controller/config/production/routing.yml deleted file mode 100644 index 175b11f130..0000000000 --- a/tests/controller/config/production/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -core_controller: - pattern: /core_foo - defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/ext/vendor2/bar/config/development/routing.yml b/tests/controller/ext/vendor2/bar/config/development/routing.yml new file mode 100644 index 0000000000..85c93b453f --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/development/routing.yml @@ -0,0 +1,3 @@ +controller3: + pattern: /bar + defaults: { _controller: bar.controller:handle } diff --git a/tests/controller/ext/vendor2/bar/config/production/routing.yml b/tests/controller/ext/vendor2/bar/config/production/routing.yml deleted file mode 100644 index 85c93b453f..0000000000 --- a/tests/controller/ext/vendor2/bar/config/production/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -controller3: - pattern: /bar - defaults: { _controller: bar.controller:handle } -- cgit v1.2.1 From dd4f2387fd2f4df0e1513c251c9044f5bef60618 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 19:50:07 +0100 Subject: [ticket/12620] Use the test environment for the tests PHPBB3-12620 --- tests/controller/config/development/routing.yml | 3 --- tests/controller/config/test/routing.yml | 3 +++ tests/controller/ext/vendor2/bar/config/development/routing.yml | 3 --- tests/controller/ext/vendor2/bar/config/test/routing.yml | 3 +++ 4 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 tests/controller/config/development/routing.yml create mode 100644 tests/controller/config/test/routing.yml delete mode 100644 tests/controller/ext/vendor2/bar/config/development/routing.yml create mode 100644 tests/controller/ext/vendor2/bar/config/test/routing.yml (limited to 'tests/controller') diff --git a/tests/controller/config/development/routing.yml b/tests/controller/config/development/routing.yml deleted file mode 100644 index 175b11f130..0000000000 --- a/tests/controller/config/development/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -core_controller: - pattern: /core_foo - defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/config/test/routing.yml b/tests/controller/config/test/routing.yml new file mode 100644 index 0000000000..175b11f130 --- /dev/null +++ b/tests/controller/config/test/routing.yml @@ -0,0 +1,3 @@ +core_controller: + pattern: /core_foo + defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/ext/vendor2/bar/config/development/routing.yml b/tests/controller/ext/vendor2/bar/config/development/routing.yml deleted file mode 100644 index 85c93b453f..0000000000 --- a/tests/controller/ext/vendor2/bar/config/development/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -controller3: - pattern: /bar - defaults: { _controller: bar.controller:handle } diff --git a/tests/controller/ext/vendor2/bar/config/test/routing.yml b/tests/controller/ext/vendor2/bar/config/test/routing.yml new file mode 100644 index 0000000000..85c93b453f --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/test/routing.yml @@ -0,0 +1,3 @@ +controller3: + pattern: /bar + defaults: { _controller: bar.controller:handle } -- cgit v1.2.1 From ac0ff219c61bd187dd3fbde5b6808624bd8ef077 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 19 Nov 2014 20:04:00 +0100 Subject: [ticket/12620] Move the routing.yml file to routing/environment.yml PHPBB3-12620 --- tests/controller/config/test/routing.yml | 3 --- tests/controller/config/test/routing/environment.yml | 3 +++ tests/controller/ext/vendor2/bar/config/test/routing.yml | 3 --- tests/controller/ext/vendor2/bar/config/test/routing/environment.yml | 3 +++ 4 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 tests/controller/config/test/routing.yml create mode 100644 tests/controller/config/test/routing/environment.yml delete mode 100644 tests/controller/ext/vendor2/bar/config/test/routing.yml create mode 100644 tests/controller/ext/vendor2/bar/config/test/routing/environment.yml (limited to 'tests/controller') diff --git a/tests/controller/config/test/routing.yml b/tests/controller/config/test/routing.yml deleted file mode 100644 index 175b11f130..0000000000 --- a/tests/controller/config/test/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -core_controller: - pattern: /core_foo - defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/config/test/routing/environment.yml b/tests/controller/config/test/routing/environment.yml new file mode 100644 index 0000000000..175b11f130 --- /dev/null +++ b/tests/controller/config/test/routing/environment.yml @@ -0,0 +1,3 @@ +core_controller: + pattern: /core_foo + defaults: { _controller: core_foo.controller:bar } diff --git a/tests/controller/ext/vendor2/bar/config/test/routing.yml b/tests/controller/ext/vendor2/bar/config/test/routing.yml deleted file mode 100644 index 85c93b453f..0000000000 --- a/tests/controller/ext/vendor2/bar/config/test/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -controller3: - pattern: /bar - defaults: { _controller: bar.controller:handle } diff --git a/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml new file mode 100644 index 0000000000..85c93b453f --- /dev/null +++ b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml @@ -0,0 +1,3 @@ +controller3: + pattern: /bar + defaults: { _controller: bar.controller:handle } -- cgit v1.2.1 From 677b5b2cd4937ee6c777728082084c661223dee8 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 20 Nov 2014 22:40:37 +0100 Subject: [ticket/12620] Fix rebase PHPBB3-12620 --- tests/controller/common_helper_route.php | 6 +++--- tests/controller/controller_test.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 5baa846ec3..19d40cf071 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -113,8 +113,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php'); - $this->router->find_routing_files($finder); + $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router->find_routing_files($this->extension_manager->all_enabled()); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); @@ -319,7 +319,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $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), $description); } -//TODO + public function helper_url_data_absolute_with_rewrite() { return array( diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 637e9685e6..354a902831 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,8 +40,8 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php'); - $router->find_routing_files($this->extension_manager->get_finder()); + $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router->find_routing_files($this->extension_manager->all_enabled()); $routes = $router->find(__DIR__)->get_routes(); // This will need to be updated if any new routes are defined -- cgit v1.2.1 From 6842831d6baa59425ec83cc2ebbae377942824ce Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sat, 17 Jan 2015 11:05:18 +0100 Subject: [ticket/13513] Use paths relative to the phpBB root in the router PHPBB3-13513 --- tests/controller/common_helper_route.php | 2 +- tests/controller/controller_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 19d40cf071..3f98d51f16 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -114,7 +114,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ); $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); - $this->router->find_routing_files($this->extension_manager->all_enabled()); + $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 354a902831..86615fe4dc 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -41,7 +41,7 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); - $router->find_routing_files($this->extension_manager->all_enabled()); + $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); // This will need to be updated if any new routes are defined -- cgit v1.2.1 From 216fb13c2ad119e3a7f1b3aea497fdb825c80136 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Tue, 3 Feb 2015 16:30:41 +0100 Subject: [ticket/13407] Remove the last occurence of pattern in routing files PHPBB3-13407 --- tests/controller/ext/vendor2/bar/config/test/routing/environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/controller') diff --git a/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml index 85c93b453f..5696ecb180 100644 --- a/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml +++ b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml @@ -1,3 +1,3 @@ controller3: - pattern: /bar + path: /bar defaults: { _controller: bar.controller:handle } -- cgit v1.2.1 From 4bdef6fd21a5dcab455b0cd1ee2652de606929c3 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Thu, 12 Mar 2015 00:25:00 +0100 Subject: [ticket/13697] Moving filesystem related functions to filesystem service * Moving filesystem service to \phpbb\filesystem namespace * Wraping Symfony's Filesystem component * Moving filesystem related functions from includes/functions.php into \phpbb\filesystem\filesystem Functions moved (and deprecated): - phpbb_chmod - phpbb_is_writable - phpbb_is_absolute - phpbb_own_realpath - phpbb_realpath * Adding interface for filesystem service PHPBB3-13697 --- tests/controller/common_helper_route.php | 6 +++--- tests/controller/controller_test.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 3f98d51f16..91b0cda68d 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -69,7 +69,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->symfony_request = new \phpbb\symfony_request( $this->request ); - $this->filesystem = new \phpbb\filesystem(); + $this->filesystem = new \phpbb\filesystem\filesystem(); $this->phpbb_path_helper = new \phpbb\path_helper( $this->symfony_request, $this->filesystem, @@ -84,7 +84,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader(''); + $loader = new \phpbb\template\twig\loader($this->filesystem, ''); $twig = new \phpbb\template\twig\environment( $this->config, $this->phpbb_path_helper, @@ -113,7 +113,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router = new phpbb_mock_router($this->filesystem, $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 86615fe4dc..a837e25f66 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,7 +40,7 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); -- cgit v1.2.1 From 57072a1e28061ff51148c7d6a0c47664f0060639 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Wed, 29 Apr 2015 00:13:29 +0200 Subject: [ticket/13793] Remove translation on throwing exceptions PHPBB3-13793 --- tests/controller/controller_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/controller') diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index a837e25f66..5c0290ee6f 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -82,7 +82,7 @@ class phpbb_controller_controller_test extends phpbb_test_case include(__DIR__.'/phpbb/controller/foo.php'); } - $resolver = new \phpbb\controller\resolver(new \phpbb\user('\phpbb\datetime'), $container, dirname(__FILE__) . '/'); + $resolver = new \phpbb\controller\resolver($container, dirname(__FILE__) . '/'); $symfony_request = new Request(); $symfony_request->attributes->set('_controller', 'foo.controller:handle'); -- cgit v1.2.1 From 179a4700221aa49071b07d638c44b9326c7a14a8 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Tue, 14 Apr 2015 02:31:23 +0200 Subject: [ticket/13762] Moving language related functionality into a separate class PHPBB3-13762 --- tests/controller/common_helper_route.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index f1f369cce6..3e4b5fd38d 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -84,7 +84,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ); $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->user = new \phpbb\user('\phpbb\datetime'); + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $this->user = new \phpbb\user($lang, '\phpbb\datetime');; $container = new phpbb_mock_container_builder(); $cache_path = $phpbb_root_path . 'cache/twig'; -- cgit v1.2.1 From 74dbaac0394f45955553ff46515404fe5b06bfba Mon Sep 17 00:00:00 2001 From: MateBartus Date: Thu, 30 Apr 2015 22:40:17 +0200 Subject: [ticket/13800] Make router's extension manager dependency optional PHPBB3-13800 --- tests/controller/common_helper_route.php | 2 +- tests/controller/controller_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 3e4b5fd38d..6910530279 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -120,7 +120,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($this->filesystem, $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router = new phpbb_mock_router($this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 5c0290ee6f..5781d3ebc1 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,7 +40,7 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); -- cgit v1.2.1 From 51376a43919cba7a5037edb7cc31f18b5950437b Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Mon, 4 May 2015 23:50:16 +0200 Subject: [ticket/13638] Inject $filesystem in \phpbb\template\asset PHPBB3-13638 --- tests/controller/common_helper_route.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 3e4b5fd38d..b01241e105 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -94,6 +94,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $loader = new \phpbb\template\twig\loader($this->filesystem, ''); $twig = new \phpbb\template\twig\environment( $this->config, + $this->filesystem, $this->phpbb_path_helper, $container, $cache_path, -- cgit v1.2.1 From 7b301e22f32e9209bb4e3ea17a5637a84a4ef908 Mon Sep 17 00:00:00 2001 From: MateBartus Date: Fri, 1 May 2015 19:04:21 +0200 Subject: [ticket/13804] Make template's user dependency optional PHPBB3-13804 --- tests/controller/common_helper_route.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index b01241e105..e2f15d85fa 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -107,7 +107,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 'autoescape' => false, ) ); - $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user))); + $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, $this->user))); $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); $this->extension_manager = new phpbb_mock_extension_manager( -- cgit v1.2.1 From 66c0e0c6a83fbf091aa078ab06dd6467c8c6aa11 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 4 May 2015 15:10:33 +0200 Subject: [ticket/13388] Integrate routing and di parameters resolution PHPBB3-13388 --- tests/controller/common_helper_route.php | 24 +++++++++++++++++++++- tests/controller/controller_test.php | 5 ++++- .../controller/ext/vendor2/foo/config/routing.yml | 4 ++++ 3 files changed, 31 insertions(+), 2 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 44e5e12ab0..3c74c16bae 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -89,6 +89,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->user = new \phpbb\user($lang, '\phpbb\datetime');; $container = new phpbb_mock_container_builder(); + $container->setParameter('core.environment', PHPBB_ENVIRONMENT); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); $loader = new \phpbb\template\twig\loader($this->filesystem, ''); @@ -121,7 +122,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); + $this->router = new phpbb_mock_router($container, $this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); // Set correct current phpBB root path @@ -155,6 +156,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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'), + + // Resolves DI parameters + array('controller4', array(), true, false, '/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -195,6 +199,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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'), + + // Resolves DI parameters + array('controller4', array(), true, false, '/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -235,6 +242,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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'), + + // Resolves DI parameters + array('controller4', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -275,6 +285,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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'), + + // Resolves DI parameters + array('controller4', array(), true, false, 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -315,6 +328,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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'), + + // Resolves DI parameters + array('controller4', array(), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -355,6 +371,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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'), + + // Resolves DI parameters + array('controller4', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } @@ -435,6 +454,9 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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'), + + // Resolves DI parameters + array('controller4', array(), true, false, '//localhost/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'), ); } diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 5781d3ebc1..d0295d66bc 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -40,7 +40,10 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_router_find_files() { - $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); + $container = new phpbb_mock_container_builder(); + $container->setParameter('core.environment', PHPBB_ENVIRONMENT); + + $router = new \phpbb\routing\router($container, new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $router->find_routing_files($this->extension_manager->all_enabled(false)); $routes = $router->find(__DIR__)->get_routes(); diff --git a/tests/controller/ext/vendor2/foo/config/routing.yml b/tests/controller/ext/vendor2/foo/config/routing.yml index e3e8ee5f98..7d4ac7be93 100644 --- a/tests/controller/ext/vendor2/foo/config/routing.yml +++ b/tests/controller/ext/vendor2/foo/config/routing.yml @@ -5,3 +5,7 @@ controller1: include_controller2: resource: "routing_2.yml" prefix: /foo + +controller4: + path: /foo/%core.environment% + defaults: { _controller: foo.controller:handle } -- cgit v1.2.1 From 8e5e954438b232f4ce7aec6a5db3d52b974c07a8 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Sun, 22 Feb 2015 23:36:27 +0100 Subject: [ticket/13645] Move the feeds to controllers PHPBB3-13645 --- tests/controller/common_helper_route.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 3c74c16bae..4c0c8569a3 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -125,6 +125,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->router = new phpbb_mock_router($container, $this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router->find_routing_files($this->extension_manager->all_enabled(false)); $this->router->find(dirname(__FILE__) . '/'); + // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); } @@ -168,7 +169,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_no_rewrite($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->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $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); } @@ -211,7 +213,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $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); } @@ -254,7 +257,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $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); } @@ -297,7 +301,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $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); } @@ -340,7 +345,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $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); } @@ -383,7 +389,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $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); } @@ -423,7 +430,8 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $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); } @@ -466,7 +474,8 @@ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); + $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); } } -- cgit v1.2.1 From 403c647b9e84640977ca0f98d21d15ceb4957bdb Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 7 Oct 2015 23:09:13 +0200 Subject: [ticket/14220] Move route loading to services PHPBB3-14220 --- tests/controller/common_helper_route.php | 8 +++++--- tests/controller/controller_test.php | 11 +++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 4c0c8569a3..72c5328b0b 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -122,9 +122,11 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); - $this->router = new phpbb_mock_router($container, $this->filesystem, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); - $this->router->find_routing_files($this->extension_manager->all_enabled(false)); - $this->router->find(dirname(__FILE__) . '/'); + $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( + new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/') + ); + $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); + $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index d0295d66bc..431b26b2bc 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -38,14 +38,17 @@ class phpbb_controller_controller_test extends phpbb_test_case )); } - public function test_router_find_files() + public function test_router_default_loader() { $container = new phpbb_mock_container_builder(); $container->setParameter('core.environment', PHPBB_ENVIRONMENT); - $router = new \phpbb\routing\router($container, new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT, $this->extension_manager); - $router->find_routing_files($this->extension_manager->all_enabled(false)); - $routes = $router->find(__DIR__)->get_routes(); + $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( + new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/') + ); + $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); + $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $routes = $router->get_routes(); // This will need to be updated if any new routes are defined $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('core_controller')); -- cgit v1.2.1 From 56c2caf6c0778c0da48fe0ac688c893777b89ee4 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 23 Mar 2016 22:48:58 +0100 Subject: [ticket/14555] Uniformize cache directory usages PHPBB3-14555 --- tests/controller/common_helper_route.php | 2 +- tests/controller/controller_test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 72c5328b0b..808eb684f2 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -126,7 +126,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); - $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 431b26b2bc..e8af2f7485 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -47,7 +47,7 @@ class phpbb_controller_controller_test extends phpbb_test_case new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); - $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); $routes = $router->get_routes(); // This will need to be updated if any new routes are defined -- cgit v1.2.1 From a5f1ff85634eb8936afd109395fc1d305eaca61e Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 27 Mar 2016 20:06:02 +0200 Subject: [ticket/13683] Fix merge into 3.2.x PHPBB3-13683 --- tests/controller/common_helper_route.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index f0dd5706f1..a26157c2b2 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -500,15 +500,14 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 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', 443, '/my/board', 'http', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/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', 443, '/my/board', 'http', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/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'), - ); + 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'), ); } /** -- cgit v1.2.1 From 14e8113fcf01be7dbdb080458fcbf4e75668cc1a Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 31 Mar 2016 11:06:47 -0700 Subject: [ticket/14576] Move common required files to bootstrap PHPBB3-14576 --- tests/controller/common_helper_route.php | 2 -- tests/controller/controller_test.php | 2 -- tests/controller/helper_route_adm_subdir_test.php | 1 - tests/controller/helper_route_adm_test.php | 1 - tests/controller/helper_route_root_test.php | 1 - tests/controller/helper_route_slash_test.php | 1 - tests/controller/helper_route_unclean_path_test.php | 1 - 7 files changed, 9 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 808eb684f2..c23342bc57 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -11,8 +11,6 @@ * */ -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 diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index e8af2f7485..abc1124a90 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -11,8 +11,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/tests/controller/helper_route_adm_subdir_test.php b/tests/controller/helper_route_adm_subdir_test.php index f27ac81b04..a1bf1b8805 100644 --- a/tests/controller/helper_route_adm_subdir_test.php +++ b/tests/controller/helper_route_adm_subdir_test.php @@ -11,7 +11,6 @@ * */ -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 diff --git a/tests/controller/helper_route_adm_test.php b/tests/controller/helper_route_adm_test.php index 86dc36ef1f..6ee394eaaa 100644 --- a/tests/controller/helper_route_adm_test.php +++ b/tests/controller/helper_route_adm_test.php @@ -11,7 +11,6 @@ * */ -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 diff --git a/tests/controller/helper_route_root_test.php b/tests/controller/helper_route_root_test.php index 63a2f2f8f7..12462e076d 100644 --- a/tests/controller/helper_route_root_test.php +++ b/tests/controller/helper_route_root_test.php @@ -11,7 +11,6 @@ * */ -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 diff --git a/tests/controller/helper_route_slash_test.php b/tests/controller/helper_route_slash_test.php index 3db5ec19e5..c781a6943e 100644 --- a/tests/controller/helper_route_slash_test.php +++ b/tests/controller/helper_route_slash_test.php @@ -11,7 +11,6 @@ * */ -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 diff --git a/tests/controller/helper_route_unclean_path_test.php b/tests/controller/helper_route_unclean_path_test.php index 9d8b62bc1c..80f1a99fff 100644 --- a/tests/controller/helper_route_unclean_path_test.php +++ b/tests/controller/helper_route_unclean_path_test.php @@ -11,7 +11,6 @@ * */ -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 -- cgit v1.2.1 From 91045879df2ee9918c7a03a58c64a74335ac67c1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 30 Mar 2016 17:44:38 +0200 Subject: [ticket/13502] Test getArguments() method of controller resolver PHPBB3-13502 --- tests/controller/controller_test.php | 57 ++++++++++++++++++++----- tests/controller/ext/vendor2/foo/controller.php | 12 +++++- 2 files changed, 57 insertions(+), 12 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index abc1124a90..8bd7bf678c 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -11,6 +11,9 @@ * */ +include_once(__DIR__ . '/ext/vendor2/foo/controller.php'); +include_once(__DIR__.'/phpbb/controller/foo.php'); + use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -64,7 +67,7 @@ class phpbb_controller_controller_test extends phpbb_test_case $this->assertNull($routes->get('controller_noroute')); } - public function test_controller_resolver() + protected function get_foo_container() { $container = new ContainerBuilder(); // YamlFileLoader only uses one path at a time, so we need to loop @@ -75,26 +78,58 @@ class phpbb_controller_controller_test extends phpbb_test_case $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'); - } + return $container; + } + + public function test_controller_resolver() + { + $container = $this->get_foo_container(); $resolver = new \phpbb\controller\resolver($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')); + $this->assertEquals(array('foo'), $resolver->getArguments($symfony_request, $resolver->getController($symfony_request))); $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')); + $this->assertEquals(array(), $resolver->getArguments($symfony_request, $resolver->getController($symfony_request))); + } + + public function data_get_arguments() + { + return array( + array(array(new foo\controller(), 'handle2'), array('foo', 0)), + array(array(new foo\controller(), 'handle_fail'), array('default'), array('no_default' => 'default')), + array(array(new foo\controller(), 'handle_fail'), array(), array(), '\phpbb\controller\exception', 'CONTROLLER_ARGUMENT_VALUE_MISSING'), + array('', array(), array(), '\ReflectionException', 'Function () does not exist'), + array(new foo\controller(), array(), array(), '\ReflectionException', 'Method __invoke does not exist'), + ); + } + + /** + * @dataProvider data_get_arguments + */ + public function test_get_arguments($input, $expected, $set_attributes = array(), $exception = '', $exception_message = '') + { + $container = $this->get_foo_container(); + + $resolver = new \phpbb\controller\resolver($container, dirname(__FILE__) . '/'); + $symfony_request = new Request(); + + foreach ($set_attributes as $name => $value) + { + $symfony_request->attributes->set($name, $value); + } + + if (!empty($exception)) + { + $this->setExpectedException($exception, $exception_message); + } + + $this->assertEquals($expected, $resolver->getArguments($symfony_request, $input)); } } diff --git a/tests/controller/ext/vendor2/foo/controller.php b/tests/controller/ext/vendor2/foo/controller.php index ce2233b3c9..b2c3df616c 100644 --- a/tests/controller/ext/vendor2/foo/controller.php +++ b/tests/controller/ext/vendor2/foo/controller.php @@ -11,8 +11,18 @@ class controller * * @return null */ - public function handle() + public function handle($optional = 'foo') { return new Response('Test', 200); } + + public function handle2($foo = 'foo', $very_optional = 0) + { + return new Response('Test2', 200); + } + + public function handle_fail($no_default) + { + return new Response('Test_fail', 200); + } } -- cgit v1.2.1 From 01d56673889cb12a11fca24b62f6e93e1c9f8dd8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 30 Mar 2016 17:49:10 +0200 Subject: [ticket/13502] Also cover passing object to resolver in tests PHPBB3-13502 --- tests/controller/controller_test.php | 3 ++- tests/controller/ext/vendor2/foo/controller.php | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/controller') diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 8bd7bf678c..d921d0eade 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -104,9 +104,10 @@ class phpbb_controller_controller_test extends phpbb_test_case return array( array(array(new foo\controller(), 'handle2'), array('foo', 0)), array(array(new foo\controller(), 'handle_fail'), array('default'), array('no_default' => 'default')), + array(new foo\controller(), array(), array()), array(array(new foo\controller(), 'handle_fail'), array(), array(), '\phpbb\controller\exception', 'CONTROLLER_ARGUMENT_VALUE_MISSING'), array('', array(), array(), '\ReflectionException', 'Function () does not exist'), - array(new foo\controller(), array(), array(), '\ReflectionException', 'Method __invoke does not exist'), + array(new phpbb\controller\foo, array(), array(), '\ReflectionException', 'Method __invoke does not exist'), ); } diff --git a/tests/controller/ext/vendor2/foo/controller.php b/tests/controller/ext/vendor2/foo/controller.php index b2c3df616c..cabcae042b 100644 --- a/tests/controller/ext/vendor2/foo/controller.php +++ b/tests/controller/ext/vendor2/foo/controller.php @@ -25,4 +25,9 @@ class controller { return new Response('Test_fail', 200); } + + public function __invoke() + { + $this->handle(); + } } -- cgit v1.2.1 From 663e3bc64238668ec139b53ccfb2f82a1d306601 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Wed, 23 Mar 2016 21:59:40 +0100 Subject: [ticket/13616] Updates direct call to twig environment constructor PHPBB3-13616 --- tests/controller/common_helper_route.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index c23342bc57..21397d0f77 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -95,7 +95,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->config, $this->filesystem, $this->phpbb_path_helper, - $container, $cache_path, null, $loader, @@ -107,7 +106,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ) ); $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, $this->user))); - $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig)); + $twig->setLexer(new \phpbb\template\twig\lexer($twig)); $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', -- cgit v1.2.1 From fcc8e155ec309669bebbf6e0370cecfe64c95193 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 16 Apr 2017 20:53:59 +0700 Subject: [ticket/14990] Move dispatcher object to the front of the options array PHPBB3-14990 --- tests/controller/common_helper_route.php | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/controller') diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 367c15a667..ea2bc042b1 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -114,6 +114,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $cache_path, null, $loader, + new \phpbb\event\dispatcher($container), array( 'cache' => false, 'debug' => false, -- cgit v1.2.1