[ticket/212] Add tests for moving modules
B3P-212
This commit is contained in:
@@ -834,7 +834,7 @@ class portal_module
|
|||||||
*
|
*
|
||||||
* @param int $module_id ID of the module that should be moved
|
* @param int $module_id ID of the module that should be moved
|
||||||
*/
|
*/
|
||||||
protected function move_module_up($module_id)
|
public function move_module_up($module_id)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT module_order, module_column
|
$sql = 'SELECT module_order, module_column
|
||||||
FROM ' . PORTAL_MODULES_TABLE . '
|
FROM ' . PORTAL_MODULES_TABLE . '
|
||||||
|
|||||||
33
tests/acp/fixtures/modules.xml
Normal file
33
tests/acp/fixtures/modules.xml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<dataset>
|
||||||
|
<table name="phpbb_portal_modules">
|
||||||
|
<column>module_id</column>
|
||||||
|
<column>module_classname</column>
|
||||||
|
<column>module_column</column>
|
||||||
|
<column>module_order</column>
|
||||||
|
<row>
|
||||||
|
<value>1</value>
|
||||||
|
<value>\board3\portal\modules\clock</value>
|
||||||
|
<value>2</value>
|
||||||
|
<value>1</value>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>2</value>
|
||||||
|
<value>\board3\portal\modules\birthday_list</value>
|
||||||
|
<value>2</value>
|
||||||
|
<value>2</value>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>3</value>
|
||||||
|
<value>\board3\portal\modules\clock</value>
|
||||||
|
<value>4</value>
|
||||||
|
<value>1</value>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<value>4</value>
|
||||||
|
<value>\board3\portal\modules\birthday_list</value>
|
||||||
|
<value>4</value>
|
||||||
|
<value>2</value>
|
||||||
|
</row>
|
||||||
|
</table>
|
||||||
|
</dataset>
|
||||||
73
tests/acp/move_module_test.php
Normal file
73
tests/acp/move_module_test.php
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?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\acp;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
global $db, $cache, $phpbb_root_path, $phpEx, $user, $phpbb_container, $template;
|
||||||
|
$user = new \board3\portal\tests\mock\user();
|
||||||
|
$phpbb_container = new \phpbb_mock_container_builder();
|
||||||
|
// Mock version check
|
||||||
|
$phpbb_container->set('board3.version.check',
|
||||||
|
$this->getMockBuilder('\board3\portal\includes\mod_version_check')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock());
|
||||||
|
// Mock module service collection
|
||||||
|
$phpbb_container->set('board3.module_collection',
|
||||||
|
array(
|
||||||
|
new \board3\portal\modules\clock(),
|
||||||
|
new \board3\portal\modules\birthday_list(new \phpbb\config\config(array()), $template, $this->db, $user),
|
||||||
|
));
|
||||||
|
$cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists'));
|
||||||
|
$cache->expects($this->any())
|
||||||
|
->method('destroy')
|
||||||
|
->with($this->equalTo('portal_modules'));
|
||||||
|
$cache->expects($this->any())
|
||||||
|
->method('sql_exists')
|
||||||
|
->with($this->anything());
|
||||||
|
$db = $this->db;
|
||||||
|
$this->portal_module = new \board3\portal\acp\portal_module();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDataSet()
|
||||||
|
{
|
||||||
|
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/modules.xml');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_move_module_up()
|
||||||
|
{
|
||||||
|
self::$redirected = false;
|
||||||
|
$this->portal_module->move_module_up(2);
|
||||||
|
$this->assertTrue(self::$redirected);
|
||||||
|
|
||||||
|
$this->setExpectedTriggerError(E_USER_NOTICE);
|
||||||
|
self::$redirected = false;
|
||||||
|
$this->portal_module->move_module_up(2);
|
||||||
|
$this->assertFalse(self::$redirected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirect($url)
|
||||||
|
{
|
||||||
|
phpbb_acp_move_module_test::$redirected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function adm_back_link($url)
|
||||||
|
{
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user