[ticket/216] Get full test coverage on move_module_left & move_module_right
B3P-216
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
<row>
|
<row>
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
<value>\board3\portal\modules\birthday_list</value>
|
<value>\board3\portal\modules\birthday_list</value>
|
||||||
<value>1</value>
|
<value>2</value>
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
|
|||||||
@@ -56,6 +56,17 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
'UNABLE_TO_MOVE_ROW' => 'UNABLE_TO_MOVE_ROW',
|
'UNABLE_TO_MOVE_ROW' => 'UNABLE_TO_MOVE_ROW',
|
||||||
));
|
));
|
||||||
$this->portal_module = new \board3\portal\acp\portal_module();
|
$this->portal_module = new \board3\portal\acp\portal_module();
|
||||||
|
$this->update_portal_modules();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function update_portal_modules()
|
||||||
|
{
|
||||||
|
$this->portal_module->module_column = array();
|
||||||
|
$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']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDataSet()
|
public function getDataSet()
|
||||||
@@ -77,7 +88,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(3, 1),
|
array(3, 1),
|
||||||
array(1, 2),
|
array(2, 2),
|
||||||
array(2, 3),
|
array(2, 3),
|
||||||
array(1, 4),
|
array(1, 4),
|
||||||
);
|
);
|
||||||
@@ -106,16 +117,12 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
public function test_move_module_down()
|
public function test_move_module_down()
|
||||||
{
|
{
|
||||||
self::$redirected = false;
|
self::$redirected = false;
|
||||||
$this->portal_module->move_module_down(1);
|
$this->portal_module->move_module_down(3);
|
||||||
$this->assertTrue(self::$redirected);
|
|
||||||
|
|
||||||
self::$redirected = false;
|
|
||||||
$this->portal_module->move_module_down(1);
|
|
||||||
$this->assertTrue(self::$redirected);
|
$this->assertTrue(self::$redirected);
|
||||||
|
|
||||||
$this->setExpectedTriggerError(E_USER_NOTICE, 'UNABLE_TO_MOVE_ROW');
|
$this->setExpectedTriggerError(E_USER_NOTICE, 'UNABLE_TO_MOVE_ROW');
|
||||||
self::$redirected = false;
|
self::$redirected = false;
|
||||||
$this->portal_module->move_module_down(1);
|
$this->portal_module->move_module_down(3);
|
||||||
$this->assertFalse(self::$redirected);
|
$this->assertFalse(self::$redirected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,16 +160,19 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
public function data_move_module_right()
|
public function data_move_module_right()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(2, 1, 1, 1),
|
array(6, 1, 2),
|
||||||
array(6, 1, 2, 2),
|
array(6, 1, 1, 2),
|
||||||
array(7, 4, 0, 0),
|
array(7, 4, 0),
|
||||||
|
array(5, 2, 0),
|
||||||
|
array(1, 1, 1, 3),
|
||||||
|
array(2, 2, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider data_move_module_right
|
* @dataProvider data_move_module_right
|
||||||
*/
|
*/
|
||||||
public function test_move_module_right($module_id, $column_start, $move_right, $move_left)
|
public function test_move_module_right($module_id, $column_start, $move_right, $add_to_column = false)
|
||||||
{
|
{
|
||||||
if ($column_start > 3)
|
if ($column_start > 3)
|
||||||
{
|
{
|
||||||
@@ -170,12 +180,20 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
$this->portal_module->move_module_right($module_id);
|
$this->portal_module->move_module_right($module_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
for ($i = 1; $i <= $move_right; $i++)
|
for ($i = 1; $i <= $move_right; $i++)
|
||||||
{
|
{
|
||||||
$data = $this->portal_module->get_move_module_data($module_id);
|
$data = $this->portal_module->get_move_module_data($module_id);
|
||||||
$this->assertEquals($column_start, $data['module_column']);
|
$this->assertEquals($column_start, $data['module_column']);
|
||||||
$this->portal_module->move_module_right($module_id);
|
$this->portal_module->move_module_right($module_id);
|
||||||
$column_start++;
|
$column_start++;
|
||||||
|
$this->update_portal_modules();
|
||||||
}
|
}
|
||||||
$this->setExpectedTriggerError(E_USER_NOTICE, 'UNABLE_TO_MOVE');
|
$this->setExpectedTriggerError(E_USER_NOTICE, 'UNABLE_TO_MOVE');
|
||||||
$this->portal_module->move_module_right($module_id);
|
$this->portal_module->move_module_right($module_id);
|
||||||
@@ -184,16 +202,19 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
public function data_move_module_left()
|
public function data_move_module_left()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array(2, 1, 1, 1),
|
array(1, 1, 1, 1),
|
||||||
array(6, 1, 2, 2),
|
array(6, 1, 2, 2),
|
||||||
|
array(5, 2, 0, 0),
|
||||||
|
array(6, 1, 2, 1, 2),
|
||||||
array(7, 4, 0, 0),
|
array(7, 4, 0, 0),
|
||||||
|
array(2, 2, 0, 0, 1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider data_move_module_left
|
* @dataProvider data_move_module_left
|
||||||
*/
|
*/
|
||||||
public function test_move_module_left($module_id, $column_start, $move_right, $move_left)
|
public function test_move_module_left($module_id, $column_start, $move_right, $move_left, $add_to_column = false)
|
||||||
{
|
{
|
||||||
if ($column_start > 3)
|
if ($column_start > 3)
|
||||||
{
|
{
|
||||||
@@ -201,14 +222,22 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
$this->portal_module->move_module_left($module_id);
|
$this->portal_module->move_module_left($module_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = 1; $i <= $move_right; $i++)
|
for ($i = 1; $i <= $move_right; $i++)
|
||||||
{
|
{
|
||||||
$data = $this->portal_module->get_move_module_data($module_id);
|
$data = $this->portal_module->get_move_module_data($module_id);
|
||||||
$this->assertEquals($column_start, $data['module_column']);
|
$this->assertEquals($column_start, $data['module_column']);
|
||||||
$this->portal_module->move_module_right($module_id);
|
$this->portal_module->move_module_right($module_id);
|
||||||
|
$this->update_portal_modules();
|
||||||
$column_start++;
|
$column_start++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
// We always start in the right column = 3
|
// We always start in the right column = 3
|
||||||
$column_start = 3;
|
$column_start = 3;
|
||||||
for ($i = 1; $i <= $move_left; $i++)
|
for ($i = 1; $i <= $move_left; $i++)
|
||||||
@@ -216,6 +245,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
$data = $this->portal_module->get_move_module_data($module_id);
|
$data = $this->portal_module->get_move_module_data($module_id);
|
||||||
$this->assertEquals($column_start, $data['module_column']);
|
$this->assertEquals($column_start, $data['module_column']);
|
||||||
$this->portal_module->move_module_left($module_id);
|
$this->portal_module->move_module_left($module_id);
|
||||||
|
$this->update_portal_modules();
|
||||||
$column_start--;
|
$column_start--;
|
||||||
}
|
}
|
||||||
$this->setExpectedTriggerError(E_USER_NOTICE, 'UNABLE_TO_MOVE');
|
$this->setExpectedTriggerError(E_USER_NOTICE, 'UNABLE_TO_MOVE');
|
||||||
|
|||||||
Reference in New Issue
Block a user