diff options
Diffstat (limited to 'tests/controller/common_helper_route.php')
| -rw-r--r-- | tests/controller/common_helper_route.php | 82 | 
1 files changed, 54 insertions, 28 deletions
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 6723e3bc52..19d40cf071 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -35,10 +35,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case  		);  		$this->generate_route_objects();  		$phpbb_dispatcher = new phpbb_mock_event_dispatcher; -		$this->user = new \phpbb\user('\phpbb\datetime'); - -		$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); -		$this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $this->user, new \phpbb\template\context());  	}  	protected function get_phpbb_root_path() @@ -82,15 +78,44 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case  			$phpEx  		); -		$finder = new \phpbb\finder( -			new \phpbb\filesystem(), +		$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); +		$this->user = new \phpbb\user('\phpbb\datetime'); + +		$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, +			$this->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($this->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__) . '/', -			new phpbb_mock_cache() +			array( +				'vendor2/foo' => array( +					'ext_name' => 'vendor2/foo', +					'ext_active' => '1', +					'ext_path' => 'ext/vendor2/foo/', +				), +			)  		); -		$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', 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();  	} @@ -130,8 +155,9 @@ 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->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); +		$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->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);  	}  	public function helper_url_data_with_rewrite() @@ -170,8 +196,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->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); -		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); +		$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() @@ -210,8 +236,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->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); -		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL)); +		$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() @@ -250,8 +276,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->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); -		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH)); +		$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() @@ -290,10 +316,10 @@ 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->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()  	{  		return array( @@ -330,8 +356,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->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); -		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL)); +		$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() @@ -370,8 +396,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->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/'); -		$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH)); +		$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() @@ -410,7 +436,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->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);  	}  }  | 
