[ticket/634] Increase test coverage of acp module
B3P-634
This commit is contained in:
@@ -29,10 +29,15 @@ class template
|
||||
$this->data[$row] = array();
|
||||
}
|
||||
|
||||
$index = (sizeof($this->data[$row])) ? sizeof($this->data[$row]) : 0;
|
||||
foreach ($values as $key => $column)
|
||||
{
|
||||
$this->test_case->assertArrayNotHasKey($key, $this->data[$row]);
|
||||
$this->data[$row][$key] = $column;
|
||||
if (!isset($this->data[$row][$index]))
|
||||
{
|
||||
$this->data[$row][$index] = array();
|
||||
}
|
||||
$this->data[$row][$index][$key] = $column;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,4 +68,9 @@ class template
|
||||
{
|
||||
unset($this->data[$key]);
|
||||
}
|
||||
|
||||
public function get_row($row)
|
||||
{
|
||||
return $this->data[$row];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
|
||||
namespace board3\portal\portal\modules;
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../acp/portal_module.php');
|
||||
|
||||
class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\database_test_case
|
||||
{
|
||||
static public $redirected = false;
|
||||
@@ -31,12 +28,26 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
||||
/** @var \board3\portal\includes\helper */
|
||||
protected $portal_helper;
|
||||
|
||||
/** @var \board3\portal\acp\portal_module */
|
||||
protected $portal_module;
|
||||
|
||||
/** @var \board3\portal\tests\mock\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb_mock_request */
|
||||
protected $request;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
global $db, $cache, $phpbb_root_path, $phpEx, $user, $phpbb_container, $request, $template, $table_prefix;
|
||||
global $phpbb_dispatcher;
|
||||
|
||||
$user = new \board3\portal\tests\mock\user();
|
||||
$template = new \board3\portal\tests\mock\template($this);
|
||||
$this->template = $template;
|
||||
$request = new \phpbb_mock_request;
|
||||
$this->request = $request;
|
||||
$phpbb_container = new \phpbb_mock_container_builder();
|
||||
// Mock module service collection
|
||||
$config = new \phpbb\config\config(array());
|
||||
@@ -91,6 +102,11 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
||||
));
|
||||
$this->database_handler = new \board3\portal\portal\modules\database_handler($db);
|
||||
$this->constraints_handler = new \board3\portal\portal\modules\constraints_handler($this->portal_columns, $user);
|
||||
$phpbb_dispatcher = $this->getMock('\phpbb\event\dispatcher', array('trigger_event'), array($phpbb_container));
|
||||
$phpbb_dispatcher->expects($this->any())
|
||||
->method('trigger_event')
|
||||
->with($this->anything())
|
||||
->will($this->returnArgument(1));
|
||||
|
||||
$path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
@@ -377,6 +393,32 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
||||
{
|
||||
$this->assertSame($expected, $this->constraints_handler->can_add_module($this->portal_helper->get_module($module_class), $column));
|
||||
}
|
||||
|
||||
public function test_main_wrong_mode()
|
||||
{
|
||||
$this->setExpectedTriggerError(E_USER_ERROR, 'NO_MODE');
|
||||
$this->portal_module->main(5, 'foobar');
|
||||
}
|
||||
|
||||
public function test_main_config()
|
||||
{
|
||||
$this->portal_module->main(5, 'config');
|
||||
$this->template->assert_equals(array(), 'options');
|
||||
$options = $this->template->get_row('options');
|
||||
$this->assertNotEmpty($this->template->get_row('options'));
|
||||
$this->assertEquals(true, in_array('board3_show_all_pages', $options[9]));
|
||||
}
|
||||
|
||||
public function test_main_invalid_submit()
|
||||
{
|
||||
$this->request->overwrite('submit', true, \phpbb\request\request_interface::POST);
|
||||
$this->portal_module->main(5, 'config');
|
||||
$this->template->assert_equals(array(), 'options');
|
||||
$options = $this->template->get_row('options');
|
||||
$this->assertNotEmpty($this->template->get_row('options'));
|
||||
$this->assertEquals(true, in_array('board3_show_all_pages', $options[9]));
|
||||
$this->template->assert_same(true, 'S_ERROR');
|
||||
}
|
||||
}
|
||||
|
||||
function redirect($url)
|
||||
|
||||
23
tests/unit/acp/portal_module_test.php
Normal file
23
tests/unit/acp/portal_module_test.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2014 Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace board3\portal\portal\modules;
|
||||
|
||||
use board3\portal\acp\portal_info;
|
||||
|
||||
class phpbb_acp_portal_module_test extends \board3\portal\tests\testframework\test_case
|
||||
{
|
||||
public function test_portal_info()
|
||||
{
|
||||
$portal_info = new portal_info();
|
||||
$module_info = $portal_info->module();
|
||||
$this->assertArrayHasKey('filename', $module_info);
|
||||
$this->assertSame('\board3\portal\acp\portal_module', $module_info['filename']);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_acp.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions.php');
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_acp.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/utf/utf_tools.php');
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/utf/utf_tools.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_content.php');
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
|
||||
class phpbb_unit_functions_get_user_groups_test extends \board3\portal\tests\testframework\database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
|
||||
class phpbb_functions_simple_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_ap_validate()
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
namespace board3\portal\modules;
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
|
||||
class phpbb_unit_modules_calendar_test extends \board3\portal\tests\testframework\database_test_case
|
||||
{
|
||||
protected $path_helper;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_acp.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/utf/utf_tools.php');
|
||||
|
||||
Reference in New Issue
Block a user