[ticket/416] Add class for handling portal columns
B3P-416
This commit is contained in:
@@ -43,6 +43,8 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
||||
$phpbb_container->set('board3.portal.modules_helper', new \board3\portal\includes\modules_helper(new \phpbb\auth\auth(), $config, $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();
|
||||
$phpbb_container->set('board3.portal.columns', $this->portal_columns);
|
||||
$cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists', 'get', 'put'));
|
||||
$cache->expects($this->any())
|
||||
->method('destroy')
|
||||
@@ -72,7 +74,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
||||
$portal_modules = obtain_portal_modules();
|
||||
foreach($portal_modules as $cur_module)
|
||||
{
|
||||
$this->portal_module->module_column[$cur_module['module_classname']][] = column_num_string($cur_module['module_column']);
|
||||
$this->portal_module->module_column[$cur_module['module_classname']][] = $this->portal_columns->number_to_string($cur_module['module_column']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +193,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
||||
if ($add_to_column)
|
||||
{
|
||||
$module_data = $this->portal_module->get_move_module_data($module_id);
|
||||
$this->portal_module->module_column[$module_data['module_classname']][] = column_num_string($add_to_column);
|
||||
$this->portal_module->module_column[$module_data['module_classname']][] = $this->portal_columns->number_to_string($add_to_column);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $move_right; $i++)
|
||||
@@ -242,7 +244,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
||||
if ($add_to_column)
|
||||
{
|
||||
$module_data = $this->portal_module->get_move_module_data($module_id);
|
||||
$this->portal_module->module_column[$module_data['module_classname']][] = column_num_string($add_to_column);
|
||||
$this->portal_module->module_column[$module_data['module_classname']][] = $this->portal_columns->number_to_string($add_to_column);
|
||||
}
|
||||
|
||||
// We always start in the right column = 3
|
||||
|
||||
@@ -40,6 +40,7 @@ class helper_test extends \board3\portal\tests\testframework\test_case
|
||||
$this->user->data['group_id'] = 2;
|
||||
$this->phpbb_root_path = dirname(__FILE__) . '/../../../../../../';
|
||||
$this->php_ext = 'php';
|
||||
$this->portal_columns = new \board3\portal\portal\columns();
|
||||
$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),
|
||||
);
|
||||
@@ -60,6 +61,7 @@ class helper_test extends \board3\portal\tests\testframework\test_case
|
||||
{
|
||||
$controller_helper = new \board3\portal\controller\helper(
|
||||
$this->auth,
|
||||
$this->portal_columns,
|
||||
$this->config,
|
||||
$this->template,
|
||||
$this->user,
|
||||
|
||||
@@ -14,8 +14,8 @@ class phpbb_functions_functions_modules_test extends PHPUnit_Framework_TestCase
|
||||
public function data_column_num_string()
|
||||
{
|
||||
return array(
|
||||
array(0, ''),
|
||||
array(0, false),
|
||||
array('', ''),
|
||||
array('', false),
|
||||
array('left', 1),
|
||||
array('center', 2),
|
||||
array('right', 3),
|
||||
|
||||
67
tests/unit/portal/columns_test.php
Normal file
67
tests/unit/portal/columns_test.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal Testing
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class board3_portal_columns_test extends \board3\portal\tests\testframework\test_case
|
||||
{
|
||||
protected $portal_columns;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->portal_columns = new \board3\portal\portal\columns();
|
||||
}
|
||||
public function data_column_number_string()
|
||||
{
|
||||
return array(
|
||||
array(4, 'top'),
|
||||
array(1, 'left'),
|
||||
array(2, 'center'),
|
||||
array(3, 'right'),
|
||||
array(5, 'bottom'),
|
||||
array(0, ''),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_column_number_string
|
||||
*/
|
||||
public function test_number_to_string($number, $string)
|
||||
{
|
||||
$this->assertEquals($string, $this->portal_columns->number_to_string($number));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_column_number_string
|
||||
*/
|
||||
public function test_string_to_number($number, $string)
|
||||
{
|
||||
$this->assertEquals($number, $this->portal_columns->string_to_number($string));
|
||||
}
|
||||
|
||||
public function data_column_string_constant()
|
||||
{
|
||||
return array(
|
||||
array('top', 1),
|
||||
array('left', 2),
|
||||
array('center', 4),
|
||||
array('right', 8),
|
||||
array('bottom', 16),
|
||||
array('', 0),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_column_string_constant
|
||||
*/
|
||||
public function test_string_to_constant($string, $constant)
|
||||
{
|
||||
$this->assertEquals($constant, $this->portal_columns->string_to_constant($string));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user