mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/11497] Use a mock object to define the root folder for the finder
PHPBB3-11497
This commit is contained in:
parent
0d893d65eb
commit
8d9133a30e
3 changed files with 25 additions and 3 deletions
|
@ -68,7 +68,7 @@ class helper
|
||||||
$this->phpbb_root_path = $phpbb_root_path;
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
$this->php_ext = $php_ext;
|
$this->php_ext = $php_ext;
|
||||||
$provider->set_ext_finder($manager->get_finder());
|
$provider->set_ext_finder($manager->get_finder());
|
||||||
$this->route_collection = $provider->find('./')->get_routes();
|
$this->route_collection = $provider->find($phpbb_root_path)->get_routes();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -84,7 +84,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||||
*/
|
*/
|
||||||
public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
|
public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
|
||||||
{
|
{
|
||||||
$this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager,'', 'php');
|
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, '', 'php', dirname(__FILE__) . '/');
|
||||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
|
||||||
public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
|
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->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
|
||||||
$this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager,'', 'php');
|
$this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, '', 'php', dirname(__FILE__) . '/');
|
||||||
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
tests/mock/controller_helper.php
Normal file
22
tests/mock/controller_helper.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2011 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class phpbb_mock_controller_helper extends \phpbb\controller\helper
|
||||||
|
{
|
||||||
|
public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
|
||||||
|
{
|
||||||
|
$this->template = $template;
|
||||||
|
$this->user = $user;
|
||||||
|
$this->config = $config;
|
||||||
|
$this->phpbb_root_path = $phpbb_root_path;
|
||||||
|
$this->php_ext = $php_ext;
|
||||||
|
$provider->set_ext_finder($manager->get_finder());
|
||||||
|
$this->route_collection = $provider->find($phpbb_root_path_ext)->get_routes();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue