[ticket/416] Add better test coverage for modules manager
B3P-416
This commit is contained in:
77
tests/unit/portal/modules_manager_test.php
Normal file
77
tests/unit/portal/modules_manager_test.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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_modules_manager_test extends \board3\portal\tests\testframework\database_test_case
|
||||
{
|
||||
protected $portal_columns;
|
||||
|
||||
/** @var \board3\portal\portal\modules\manager */
|
||||
protected $modules_manager;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/news.xml');
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$user = new \board3\portal\tests\mock\user();
|
||||
$request = new \phpbb_mock_request;
|
||||
|
||||
$config = new \phpbb\config\config(array());
|
||||
|
||||
$portal_helper = new \board3\portal\includes\helper(array(
|
||||
new \board3\portal\modules\clock($config, null),
|
||||
new \board3\portal\modules\birthday_list($config, null, $this->db, $user),
|
||||
new \board3\portal\modules\welcome($config, new \phpbb_mock_request, $this->db, $user, $this->phpbb_root_path, $this->phpEx),
|
||||
new \board3\portal\modules\donation($config, $template, $user),
|
||||
));
|
||||
|
||||
$this->portal_columns = new \board3\portal\portal\columns();
|
||||
$cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists', 'get', 'put'));
|
||||
$cache->expects($this->any())
|
||||
->method('destroy')
|
||||
->with($this->equalTo('portal_modules'));
|
||||
$cache->expects($this->any())
|
||||
->method('get')
|
||||
->with($this->anything())
|
||||
->will($this->returnValue(false));
|
||||
$cache->expects($this->any())
|
||||
->method('sql_exists')
|
||||
->with($this->anything());
|
||||
$cache->expects($this->any())
|
||||
->method('put')
|
||||
->with($this->anything());
|
||||
$db = $this->db;
|
||||
$user->set(array(
|
||||
'UNABLE_TO_MOVE' => 'UNABLE_TO_MOVE',
|
||||
'UNABLE_TO_MOVE_ROW' => 'UNABLE_TO_MOVE_ROW',
|
||||
));
|
||||
$this->database_handler = new \board3\portal\portal\modules\database_handler($db);
|
||||
$this->modules_manager = new \board3\portal\portal\modules\manager($cache, $db, $this->portal_columns, $portal_helper, $this->database_handler, $request, $user);
|
||||
}
|
||||
|
||||
public function test_set_u_action()
|
||||
{
|
||||
$this->assertInstanceOf('\board3\portal\portal\modules\manager', $this->modules_manager->set_u_action('foobar'));
|
||||
}
|
||||
|
||||
public function test_set_acp_class()
|
||||
{
|
||||
$this->assertInstanceOf('\board3\portal\portal\modules\manager', $this->modules_manager->set_acp_class('foobar'));
|
||||
}
|
||||
|
||||
public function test_get_module_link()
|
||||
{
|
||||
$this->modules_manager->set_acp_class('foo\bar')->set_u_action('index.php?i=25&mode=barfoo');
|
||||
$this->assertEquals('index.php?i=%5Cfoo%5Cbar&mode=test&module_id=5', $this->modules_manager->get_module_link('test', 5));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user