[ticket/416] Improve controller helper test coverage and fix coding issues
B3P-416
This commit is contained in:
@@ -35,7 +35,6 @@ $lang = array_merge($lang, array(
|
|||||||
'NO_ADMINISTRATORS_P' => 'No Administrators',
|
'NO_ADMINISTRATORS_P' => 'No Administrators',
|
||||||
'NO_MODERATORS_P' => 'No Moderators',
|
'NO_MODERATORS_P' => 'No Moderators',
|
||||||
'NO_GROUPS_P' => 'No Groups',
|
'NO_GROUPS_P' => 'No Groups',
|
||||||
'ACP_PORTAL_LEADERS' => 'The Team',
|
|
||||||
|
|
||||||
// ACP
|
// ACP
|
||||||
'ACP_PORTAL_LEADERS' => 'Team Settings',
|
'ACP_PORTAL_LEADERS' => 'Team Settings',
|
||||||
|
|||||||
@@ -11,10 +11,8 @@ namespace board3\portal\portal\modules;
|
|||||||
|
|
||||||
use board3\portal\includes\helper;
|
use board3\portal\includes\helper;
|
||||||
use board3\portal\portal\columns;
|
use board3\portal\portal\columns;
|
||||||
use phpbb\cache\service;
|
|
||||||
use phpbb\db\driver\driver_interface;
|
use phpbb\db\driver\driver_interface;
|
||||||
use phpbb\request\request_interface;
|
use phpbb\request\request_interface;
|
||||||
use phpbb\user;
|
|
||||||
|
|
||||||
class manager
|
class manager
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class helper_test extends \board3\portal\tests\testframework\test_case
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
global $cache;
|
global $cache, $phpbb_extension_manager;
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@@ -36,13 +36,14 @@ class helper_test extends \board3\portal\tests\testframework\test_case
|
|||||||
'board3_enable' => true,
|
'board3_enable' => true,
|
||||||
));
|
));
|
||||||
$this->template = new \board3\portal\tests\mock\template($this);
|
$this->template = new \board3\portal\tests\mock\template($this);
|
||||||
$this->user = $this->getMock('\phpbb\user', array('add_lang_ext'), array('\phpbb\datetime'));
|
$this->user = new \phpbb\user('\phpbb\datetime');
|
||||||
$this->user->data['group_id'] = 2;
|
$this->user->data['group_id'] = 2;
|
||||||
$this->phpbb_root_path = dirname(__FILE__) . '/../../../../../../';
|
$this->phpbb_root_path = dirname(__FILE__) . '/../../../../../../';
|
||||||
|
$phpbb_extension_manager = new \phpbb_mock_extension_manager($this->phpbb_root_path, array('board3/portal'));
|
||||||
$this->php_ext = 'php';
|
$this->php_ext = 'php';
|
||||||
$this->portal_columns = new \board3\portal\portal\columns();
|
$this->portal_columns = new \board3\portal\portal\columns();
|
||||||
$this->modules = array(
|
$this->modules = array(
|
||||||
'\board3\portal\modules\link_us' => new \board3\portal\modules\link_us($config, new \board3\portal\tests\mock\template($this), new \board3\portal\tests\mock\user),
|
'\board3\portal\modules\link_us' => new \board3\portal\modules\link_us($this->config, new \board3\portal\tests\mock\template($this), new \board3\portal\tests\mock\user),
|
||||||
);
|
);
|
||||||
$this->portal_helper = new \board3\portal\includes\helper($this->modules);
|
$this->portal_helper = new \board3\portal\includes\helper($this->modules);
|
||||||
$this->path_helper = new \phpbb\path_helper(
|
$this->path_helper = new \phpbb\path_helper(
|
||||||
@@ -111,7 +112,7 @@ class helper_test extends \board3\portal\tests\testframework\test_case
|
|||||||
array(false, array(
|
array(false, array(
|
||||||
'module_status' => 1,
|
'module_status' => 1,
|
||||||
'module_classname' => '\board3\portal\modules\link_us',
|
'module_classname' => '\board3\portal\modules\link_us',
|
||||||
'module_group_ids' => 3,4,
|
'module_group_ids' => '3,4',
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -124,9 +125,30 @@ class helper_test extends \board3\portal\tests\testframework\test_case
|
|||||||
$this->assertEquals(($expected) ? $this->modules['\board3\portal\modules\link_us'] : false, $this->controller_helper->get_portal_module($row));
|
$this->assertEquals(($expected) ? $this->modules['\board3\portal\modules\link_us'] : false, $this->controller_helper->get_portal_module($row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_get_portal_module_disabled_column()
|
||||||
|
{
|
||||||
|
$this->config['board3_left_column'] = false;
|
||||||
|
$this->assertEquals(false, $this->controller_helper->get_portal_module(array(
|
||||||
|
'module_status' => 1,
|
||||||
|
'module_classname' => '\board3\portal\modules\link_us',
|
||||||
|
'module_column' => 1,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
public function test_load_module_language()
|
public function test_load_module_language()
|
||||||
{
|
{
|
||||||
$this->assertNull($this->controller_helper->load_module_language($this->modules['\board3\portal\modules\link_us']));
|
$this->assertNull($this->controller_helper->load_module_language($this->modules['\board3\portal\modules\link_us']));
|
||||||
|
$this->assertEquals('Link to us', $this->user->lang('LINK_US'));
|
||||||
|
$this->assertFalse(isset($this->user->lang['PORTAL_LEADERS_EXT']));
|
||||||
|
$module = $this->getMock('\board3\portal\modules\link_us', array('get_language'), array($this->config, new \board3\portal\tests\mock\template($this), new \board3\portal\tests\mock\user));
|
||||||
|
$module->expects($this->any())
|
||||||
|
->method('get_language')
|
||||||
|
->willReturn(array(
|
||||||
|
'vendor' => 'board3/portal',
|
||||||
|
'file' => 'modules/portal_leaders_module',
|
||||||
|
));
|
||||||
|
$this->assertNull($this->controller_helper->load_module_language($module));
|
||||||
|
$this->assertEquals('Team Settings', $this->user->lang('ACP_PORTAL_LEADERS'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function data_assign_module_vars()
|
public function data_assign_module_vars()
|
||||||
|
|||||||
Reference in New Issue
Block a user