[ticket/436] Mock controller helper for unit tests

B3P-436
This commit is contained in:
Marc Alexander
2015-01-18 15:12:18 +01:00
parent b4999f2c38
commit f4ceb44124
6 changed files with 56 additions and 8 deletions

View File

@@ -53,8 +53,10 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
new \board3\portal\modules\donation($config, $template, $user),
));
$this->portal_helper = new \board3\portal\includes\helper($phpbb_container->get('board3.portal.module_collection'));
$controller_helper = new \board3\portal\tests\mock\controller_helper($phpbb_root_path, $phpEx);
$controller_helper->add_route('board3_portal_controller', 'portal');
$phpbb_container->set('board3.portal.helper', $this->portal_helper);
$phpbb_container->set('board3.portal.modules_helper', new \board3\portal\includes\modules_helper(new \phpbb\auth\auth(), $config, $request));
$phpbb_container->set('board3.portal.modules_helper', new \board3\portal\includes\modules_helper(new \phpbb\auth\auth(), $config, $controller_helper, $request));
$phpbb_container->setParameter('board3.portal.modules.table', $table_prefix . 'portal_modules');
$phpbb_container->setParameter('board3.portal.config.table', $table_prefix . 'portal_config');
$this->portal_columns = new \board3\portal\portal\columns();

View File

@@ -20,7 +20,7 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
{
parent::setUp();
global $auth, $cache, $config, $phpbb_container, $phpbb_dispatcher, $template, $user;
global $auth, $cache, $phpbb_container, $phpbb_dispatcher, $template, $user, $phpbb_root_path, $phpEx;
$user = new \phpbb\user('\phpbb\datetime');
$user->data['user_id'] = 2;
@@ -52,7 +52,9 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
$this->auth = $auth;
$this->user = $user;
$phpbb_container = new \phpbb_mock_container_builder();
$this->modules_helper = new \board3\portal\includes\modules_helper($auth, $this->config, $request);
$controller_helper = new \board3\portal\tests\mock\controller_helper($phpbb_root_path, $phpEx);
$controller_helper->add_route('board3_portal_controller', 'portal');
$this->modules_helper = new \board3\portal\includes\modules_helper($auth, $this->config, $controller_helper, $request);
$phpbb_container->set('board3.portal.modules_helper', $this->modules_helper);
$phpbb_container->set('board3.portal.fetch_posts', new \board3\portal\portal\fetch_posts($auth, $cache, $this->config, $this->db, $this->modules_helper, $user));
$template = $this->getMock('\phpbb\template', array('set_filenames', 'destroy_block_vars', 'assign_block_vars', 'assign_display'));

View File

@@ -23,13 +23,17 @@ class board3_includes_modules_helper_test extends \board3\portal\tests\testframe
public function setUp()
{
global $phpbb_root_path, $phpEx;
parent::setUp();
$auth = new \phpbb\auth\auth();
$this->config = new \phpbb\config\config(array());
$request = new \phpbb_mock_request(array('foo' => array('bar')));
$controller_helper = new \board3\portal\tests\mock\controller_helper($phpbb_root_path, $phpEx);
$controller_helper->add_route('board3_portal_controller', 'portal');
$this->modules_helper = new \board3\portal\includes\modules_helper($auth, $this->config, $request);
$this->modules_helper = new \board3\portal\includes\modules_helper($auth, $this->config, $controller_helper, $request);
}
public function data_get_disallowed_forums()

View File

@@ -28,7 +28,7 @@ class phpbb_unit_modules_calendar_test extends \board3\portal\tests\testframewor
public function setUp()
{
parent::setUp();
global $cache, $phpbb_root_path;
global $cache, $phpbb_root_path, $phpEx;
$this->path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
@@ -40,7 +40,10 @@ class phpbb_unit_modules_calendar_test extends \board3\portal\tests\testframewor
'php'
);
self::$config = new \phpbb\config\config(array());
$this->calendar = new \board3\portal\modules\calendar(self::$config, null, null, null, dirname(__FILE__) . '/../../../', 'php', null, $this->path_helper, null);
$controller_helper = new \board3\portal\tests\mock\controller_helper($phpbb_root_path, $phpEx);
$controller_helper->add_route('board3_portal_controller', 'portal');
$modules_helper = new \board3\portal\includes\modules_helper(new \phpbb\auth\auth(), new \phpbb\config\config(array()), $controller_helper, new \phpbb_mock_request());
$this->calendar = new \board3\portal\modules\calendar(self::$config, $modules_helper, null, null, null, dirname(__FILE__) . '/../../../', 'php', null, $this->path_helper, null);
define('PORTAL_MODULES_TABLE', 'phpbb_portal_modules');
define('PORTAL_CONFIG_TABLE', 'phpbb_portal_config');
$cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists', 'get', 'put'));

View File

@@ -19,7 +19,7 @@ class phpbb_portal_fetch_posts_test extends \board3\portal\tests\testframework\d
public function setUp()
{
global $auth, $cache, $phpbb_dispatcher, $template, $user;
global $auth, $cache, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $template, $user;
parent::setUp();
@@ -50,7 +50,9 @@ class phpbb_portal_fetch_posts_test extends \board3\portal\tests\testframework\d
// Pretend to allow downloads in forum 1
$auth->acl[1][0] = true;
$this->auth = $auth;
$this->modules_helper = new \board3\portal\includes\modules_helper($auth, $this->config, new phpbb_mock_request());
$controller_helper = new \board3\portal\tests\mock\controller_helper($phpbb_root_path, $phpEx);
$controller_helper->add_route('board3_portal_controller', 'portal');
$this->modules_helper = new \board3\portal\includes\modules_helper($auth, $this->config, $controller_helper, new phpbb_mock_request());
$this->user = $user;
$template = $this->getMock('\phpbb\template', array('set_filenames', 'destroy_block_vars', 'assign_block_vars', 'assign_display'));
$this->fetch_posts = new \board3\portal\portal\fetch_posts($auth, $cache, $this->config, $this->db, $this->modules_helper, $user);