Merge pull request #470 from marc1706/ticket/469

[ticket/469] Add setting for displaying portal side columns on all pages
This commit is contained in:
Marc Alexander
2015-02-14 22:51:08 +01:00
22 changed files with 458 additions and 12 deletions

View File

@@ -55,8 +55,12 @@ class portal_module
$this->portal_columns = $this->phpbb_container->get('board3.portal.columns');
$this->modules_manager = $this->phpbb_container->get('board3.portal.modules.manager');
$this->modules_constraints = $this->phpbb_container->get('board3.portal.modules.constraints_handler');
define('PORTAL_MODULES_TABLE', $this->phpbb_container->getParameter('board3.portal.modules.table'));
define('PORTAL_CONFIG_TABLE', $this->phpbb_container->getParameter('board3.portal.config.table'));
if (!defined('PORTAL_MODULES_TABLE'))
{
define('PORTAL_MODULES_TABLE', $this->phpbb_container->getParameter('board3.portal.modules.table'));
define('PORTAL_CONFIG_TABLE', $this->phpbb_container->getParameter('board3.portal.config.table'));
}
if(!function_exists('obtain_portal_config'))
{
@@ -97,6 +101,10 @@ class portal_module
'legend2' => 'ACP_PORTAL_COLUMN_WIDTH_SETTINGS',
'board3_left_column_width' => array('lang' => 'PORTAL_LEFT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'board3_right_column_width' => array('lang' => 'PORTAL_RIGHT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true),
'legend3' => 'ACP_PORTAL_SHOW_ALL',
'board3_show_all_pages' => array('lang' => 'ACP_PORTAL_SHOW_ALL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'board3_show_all_side' => array('lang' => 'PORTAL_SHOW_ALL_SIDE', 'validate' => 'bool', 'type' => 'custom', 'method' => array('board3.portal.modules_helper', 'display_left_right'), 'submit' => array('board3.portal.modules_helper', 'store_left_right'), 'explain' => true),
)
);
@@ -215,11 +223,11 @@ class portal_module
if ($null['submit'][0] == 'board3.portal.modules_helper')
{
$func = array($this->modules_helper, $null['submit'][1]);
$args = ($module_id != 0) ? array($config_name, $module_id) : $config_name;
$args = ($module_id != 0) ? array($config_name, $module_id) : array($config_name);
}
else
{
$args = ($module_id != 0) ? array($cfg_array[$config_name], $config_name, $module_id) : $config_name;
$args = ($module_id != 0) ? array($cfg_array[$config_name], $config_name, $module_id) : array($config_name);
$func = $null['submit'];
}
}

View File

@@ -87,6 +87,7 @@ services:
board3.portal.listener:
class: board3\portal\event\listener
arguments:
- @board3.portal.main
- @auth
- @config
- @controller.helper

View File

@@ -227,7 +227,7 @@ class helper
{
$this->template->assign_block_vars('modules_' . $this->portal_columns->number_to_string($row['module_column']), array(
'TEMPLATE_FILE' => 'portal/modules/' . $template_module['template'],
'IMAGE_SRC' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $template_module['image_src'],
'IMAGE_SRC' => $this->path_helper->get_web_root_path() . ltrim($this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $template_module['image_src'], './'),
'TITLE' => $template_module['title'],
'CODE' => $template_module['code'],
'MODULE_ID' => $row['module_id'],
@@ -239,7 +239,7 @@ class helper
{
$this->template->assign_block_vars('modules_' . $this->portal_columns->number_to_string($row['module_column']), array(
'TEMPLATE_FILE' => 'portal/modules/' . $template_module,
'IMAGE_SRC' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $row['module_image_src'],
'IMAGE_SRC' => $this->path_helper->get_web_root_path() . ltrim($this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $row['module_image_src'], './'),
'IMAGE_WIDTH' => $row['module_image_width'],
'IMAGE_HEIGHT' => $row['module_image_height'],
'MODULE_ID' => $row['module_id'],

View File

@@ -80,6 +80,9 @@ class main
*/
protected $portal_modules;
/** @var int Allowed columns */
protected $allowed_columns;
/**
* Constructor
* NOTE: The parameters of this method must match in order and type with
@@ -123,12 +126,18 @@ class main
/**
* Extension front handler method. This is called automatically when your extension is accessed
* through index.php?ext=example/foobar
*
* @param array $columns Columns to display
*
* @return null
*/
public function handle()
public function handle($columns = array())
{
$this->controller_helper->run_initial_tasks();
// Check if we should limit the columns to display
$this->set_allowed_columns($columns);
// Set default data
$this->portal_modules = obtain_portal_modules();
$display_online = false;
@@ -181,6 +190,14 @@ class main
// Assign specific vars
$this->assign_template_vars();
// Return if columns were specified. Columns are only specified if
// portal columns are displayed on pages other than the portal itself.
if ($this->allowed_columns !== 0)
{
$this->template->assign_var('S_PORTAL_ALL', true);
return;
}
// And now to output the page.
page_header($this->user->lang('PORTAL'), $display_online);
@@ -206,8 +223,15 @@ class main
public function get_module_template($row, $module)
{
$template_module = false;
$column = $this->portal_columns->number_to_string($row['module_column']);
// Make sure we should actually load this module
if (!$this->display_module_allowed($this->portal_columns->string_to_constant($column)))
{
return false;
}
if (in_array($column, array('left', 'right')) && $this->config['board3_' . $column . '_column'])
{
++$this->module_count[$column];
@@ -252,7 +276,7 @@ class main
'S_BOTTOM_COLUMN' => $this->check_module_count('bottom'),
'S_DISPLAY_PHPBB_MENU' => $this->config['board3_phpbb_menu'],
'B3P_DISPLAY_JUMPBOX' => $this->config['board3_display_jumpbox'],
'T_EXT_THEME_PATH' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/',
'T_EXT_THEME_PATH' => $this->path_helper->get_web_root_path() . ltrim($this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/', './'),
));
}
@@ -282,4 +306,36 @@ class main
make_jumpbox(append_sid("{$this->phpbb_root_path}viewforum{$this->php_ext}"));
}
}
/**
* Check whether displaying the module is allowed
*
* @param int $module_column The column of the module
*
* @return bool True if module can be displayed, false if not
*/
protected function display_module_allowed($module_column)
{
return ($this->allowed_columns > 0) ? (bool) ($this->allowed_columns & $module_column) : true;
}
/**
* Set allowed columns based on supplied columns array
*
* @param array $columns Allowed columns
*/
protected function set_allowed_columns($columns)
{
if (!empty($columns))
{
foreach ($columns as $column => $show)
{
$this->allowed_columns |= ($show) ? $this->portal_columns->string_to_constant($column) : 0;
}
}
else
{
$this->allowed_columns = 0;
}
}
}

View File

@@ -13,6 +13,9 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class listener implements EventSubscriberInterface
{
/** @var \board3\portal\controller\main */
protected $board3_controller;
/** @var \phpbb\auth\auth */
protected $auth;
@@ -37,6 +40,7 @@ class listener implements EventSubscriberInterface
/**
* Constructor of Board3 Portal event listener
*
* @param \board3\portal\controller\main $board3_controller Board3 Portal controller
* @param \phpbb\auth\auth $auth phpBB auth object
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\controller\helper $controller_helper Controller helper object
@@ -45,8 +49,9 @@ class listener implements EventSubscriberInterface
* @param \phpbb\user $user User object
* @param string $php_ext phpEx
*/
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\controller\helper $controller_helper, \phpbb\path_helper $path_helper, \phpbb\template\template $template, \phpbb\user $user, $php_ext)
public function __construct(\board3\portal\controller\main $board3_controller, \phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\controller\helper $controller_helper, \phpbb\path_helper $path_helper, \phpbb\template\template $template, \phpbb\user $user, $php_ext)
{
$this->board3_controller = $board3_controller;
$this->auth = $auth;
$this->config = $config;
$this->controller_helper = $controller_helper;
@@ -113,9 +118,10 @@ class listener implements EventSubscriberInterface
return;
}
if (strpos($this->user->data['session_page'], '/portal') === false)
if (strpos($this->controller_helper->get_current_url(), '/portal') === false)
{
$portal_link = $this->controller_helper->route('board3_portal_controller');
$this->display_portal();
}
else
{
@@ -136,4 +142,19 @@ class listener implements EventSubscriberInterface
{
return $this->auth->acl_get('u_view_portal') && $this->config['board3_enable'];
}
/**
* Display portal columns on all pages if specified in portal settings
*/
protected function display_portal()
{
// Check if we should show the portal
if (isset($this->config['board3_show_all_pages']) && $this->config['board3_show_all_pages'])
{
$this->board3_controller->handle(array(
'left' => $this->config['board3_show_all_side'] == false,
'right' => $this->config['board3_show_all_side'] == true,
));
}
}
}

View File

@@ -158,4 +158,32 @@ class modules_helper
{
return $this->controller_helper->route($route, $params, $is_amp, $session_id, $reference_type);
}
/**
* Display radio buttons for left/right choice
*
* @param int $value Selected value
* @param string $key Key of config variable
*
* @return string
*/
public function display_left_right($value, $key)
{
$radio_ary = array(0 => 'PORTAL_SHOW_ALL_LEFT', 1 => 'PORTAL_SHOW_ALL_RIGHT');
return h_radio($key, $radio_ary, $value, $key);
}
/**
* Store left right choice
*
* @param string $key Config key
*/
public function store_left_right($key)
{
// Get selected side
$value = $this->request->variable($key, 0);
$this->config->set($key, $value);
}
}

View File

@@ -80,6 +80,8 @@ $lang = array_merge($lang, array(
'ACP_PORTAL_CONFIG_INFO' => 'General settings',
'ACP_PORTAL_GENERAL_TITLE' => 'Portal Administration',
'ACP_PORTAL_GENERAL_TITLE_EXP' => 'Thank you for choosing Board3 Portal! This is where you can manage your portal page. The options below let you customize the various general settings.',
'ACP_PORTAL_SHOW_ALL' => 'Show portal on all pages',
'ACP_PORTAL_SHOW_ALL_EXP' => 'Display the portal on all pages',
'PORTAL_ENABLE' => 'Enable Portal',
'PORTAL_ENABLE_EXP' => 'Turns the whole portal on or off',
'PORTAL_LEFT_COLUMN' => 'Enable left column',
@@ -94,6 +96,10 @@ $lang = array_merge($lang, array(
'PORTAL_LEFT_COLUMN_WIDTH_EXP' => 'Change the width of the left column in pixels; recommended value is 180',
'PORTAL_RIGHT_COLUMN_WIDTH' => 'Width of the right column',
'PORTAL_RIGHT_COLUMN_WIDTH_EXP' => 'Change the width of the right column in pixels; recommended value is 180',
'PORTAL_SHOW_ALL_SIDE' => 'Column to display on all pages',
'PORTAL_SHOW_ALL_SIDE_EXP' => 'Choose which column should be shown on all pages.',
'PORTAL_SHOW_ALL_LEFT' => 'Left',
'PORTAL_SHOW_ALL_RIGHT' => 'Right',
'LINK_ADDED' => 'The link has been successfully added',
'LINK_UPDATED' => 'The link has been successfully updated',

27
migrations/v210_rc3.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
/**
*
* @package Board3 Portal v2.1
* @copyright (c) 2015 Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\portal\migrations;
class v210_rc3 extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return array('\board3\portal\migrations\v210_rc2');
}
public function update_data()
{
return array(
array('config.update', array('board3_portal_version', '2.1.0-rc3')),
array('config.add', array('board3_show_all_pages', 0)),
array('config.add', array('board3_show_all_side', 0)),
);
}
}

View File

@@ -0,0 +1,40 @@
<!-- IF S_PORTAL_ALL === true -->
</div>
</div>
<!-- [+] left module area -->
<!-- IF S_LEFT_COLUMN -->
<div id="portal-left" style="width: {S_PORTAL_LEFT_COLUMN}px;">
<!-- BEGIN modules_left -->
<!-- DEFINE $TEMPLATE_FILE = '{modules_left.TEMPLATE_FILE}' -->
<!-- DEFINE $IMAGE_SRC = '{modules_left.IMAGE_SRC}' -->
<!-- DEFINE $IMAGE_WIDTH = '{modules_left.IMAGE_WIDTH}' -->
<!-- DEFINE $IMAGE_HEIGHT = '{modules_left.IMAGE_HEIGHT}' -->
<!-- DEFINE $CUSTOM_CODE = '{modules_left.CODE}' -->
<!-- DEFINE $TITLE = '{modules_left.TITLE}' -->
<!-- DEFINE $MODULE_ID = '{modules_left.MODULE_ID}' -->
<!-- INCLUDE {$TEMPLATE_FILE} -->
<!-- END modules_left -->
</div>
<!-- ENDIF -->
<!-- [-] left module area -->
<!-- [+] right module area -->
<!-- IF S_RIGHT_COLUMN -->
<div id="portal-right" style="width: {S_PORTAL_RIGHT_COLUMN}px; margin-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->: -{S_PORTAL_RIGHT_COLUMN}px;">
<!-- BEGIN modules_right -->
<!-- DEFINE $TEMPLATE_FILE = '{modules_right.TEMPLATE_FILE}' -->
<!-- DEFINE $IMAGE_SRC = '{modules_right.IMAGE_SRC}' -->
<!-- DEFINE $IMAGE_WIDTH = '{modules_right.IMAGE_WIDTH}' -->
<!-- DEFINE $IMAGE_HEIGHT = '{modules_right.IMAGE_HEIGHT}' -->
<!-- DEFINE $CUSTOM_CODE = '{modules_right.CODE}' -->
<!-- DEFINE $TITLE = '{modules_right.TITLE}' -->
<!-- DEFINE $MODULE_ID = '{modules_right.MODULE_ID}' -->
<!-- INCLUDE {$TEMPLATE_FILE} -->
<!-- END modules_right -->
</div>
<!-- ENDIF -->
<!-- [-] right module area -->
<br class="portal-clear" />
</div>
</div>
<!-- ENDIF -->

View File

@@ -1,4 +1,9 @@
<!-- IF T_EXT_THEME_PATH -->
<!-- INCLUDECSS ../theme/portal.css -->
<!-- IF S_PORTAL_ALL -->
<!-- INCLUDECSS ../theme/portal_all.css -->
<!-- INCLUDECSS ../theme/portal_all_responsive.css -->
<!-- ELSE -->
<!-- INCLUDECSS ../theme/portal_responsive.css -->
<!-- ENDIF -->
<!-- ENDIF -->

View File

@@ -0,0 +1,7 @@
<!-- IF S_PORTAL_ALL === true -->
<div id="portal-page-body">
<div id="portal-body">
<div class="portal-body-wrapper">
<!-- INCLUDE portal/_block_config.html -->
<div class="portal-body-center" style="margin: 0 <!-- IF S_RIGHT_COLUMN -->{S_PORTAL_RIGHT_COLUMN}px<!-- ELSE -->-{$BLOCK_DISTANCE}<!-- ENDIF --> 0 <!-- IF S_LEFT_COLUMN -->{S_PORTAL_LEFT_COLUMN}px<!-- ELSE -->-{$BLOCK_DISTANCE}<!-- ENDIF -->; padding: 0 {$BLOCK_DISTANCE};">
<!-- ENDIF -->

View File

@@ -1,4 +1,3 @@
<!-- DEFINE $S_IN_PORTAL = 1 -->
<!-- INCLUDE overall_header.html -->
<!-- INCLUDE portal/_block_config.html -->

View File

@@ -0,0 +1,15 @@
.portal-body-wrapper {
width: 100%;
float: left;
display: block;
}
#portal-page-body {
clear: both;
margin: 4px 0;
}
#page-body {
float: left;
width: 100%;
}

View File

@@ -0,0 +1,14 @@
@media only screen and (max-width: 870px), only screen and (max-device-width: 870px) {
.portal-body-center dd.posts, .portal-body-center dd.views {
display: none !important;
}
.portal-body-center dt { width: 130% !important; }
}
@media only screen and (max-width: 740px), only screen and (max-device-width: 740px) {
.portal-body-center dt { width: 140% !important; }
#portal-left ul.topiclist dd, #portal-right ul.topiclist dd { display: block !important; }
#portal-right > .portal-clear, #portal-body > .portal-clear, #portal-left > .portal-clear,
#portal-center > .portal-clear, #portal-login-box .portal-clear { display: none !important; }
}

View File

@@ -0,0 +1,21 @@
<!-- IF S_PORTAL_ALL === true -->
</td>
<!-- [+] right module area -->
<!-- IF S_RIGHT_COLUMN -->
<td width="{S_PORTAL_RIGHT_COLUMN}px" valign="top" style="padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->right<!-- ELSE -->left<!-- ENDIF -->:{$BLOCK_DISTANCE};">
<!-- BEGIN modules_right -->
<!-- DEFINE $TEMPLATE_FILE = '{modules_right.TEMPLATE_FILE}' -->
<!-- DEFINE $IMAGE_SRC = '{modules_right.IMAGE_SRC}' -->
<!-- DEFINE $IMAGE_WIDTH = '{modules_right.IMAGE_WIDTH}' -->
<!-- DEFINE $IMAGE_HEIGHT = '{modules_right.IMAGE_HEIGHT}' -->
<!-- DEFINE $CUSTOM_CODE = '{modules_right.CODE}' -->
<!-- DEFINE $TITLE = '{modules_right.TITLE}' -->
<!-- DEFINE $MODULE_ID = '{modules_right.MODULE_ID}' -->
<!-- INCLUDE {$TEMPLATE_FILE} -->
<!-- END modules_right -->
</td>
<!-- ENDIF -->
<!-- [-] right module area -->
</tr>
</table>
<!-- ENDIF -->

View File

@@ -0,0 +1,22 @@
<!-- IF S_PORTAL_ALL === true -->
<!-- INCLUDE portal/_block_config.html -->
<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr>
<!-- [+] left module area -->
<!-- IF S_LEFT_COLUMN -->
<td width="{S_PORTAL_LEFT_COLUMN}px" valign="top" style="padding-<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->left<!-- ELSE -->right<!-- ENDIF -->:{$BLOCK_DISTANCE};">
<!-- BEGIN modules_left -->
<!-- DEFINE $TEMPLATE_FILE = '{modules_left.TEMPLATE_FILE}' -->
<!-- DEFINE $IMAGE_SRC = '{modules_left.IMAGE_SRC}' -->
<!-- DEFINE $IMAGE_WIDTH = '{modules_left.IMAGE_WIDTH}' -->
<!-- DEFINE $IMAGE_HEIGHT = '{modules_left.IMAGE_HEIGHT}' -->
<!-- DEFINE $CUSTOM_CODE = '{modules_left.CODE}' -->
<!-- DEFINE $TITLE = '{modules_left.TITLE}' -->
<!-- DEFINE $MODULE_ID = '{modules_left.MODULE_ID}' -->
<!-- INCLUDE {$TEMPLATE_FILE} -->
<!-- END modules_left -->
</td>
<!-- ENDIF -->
<!-- [-] left module area -->
<td valign="top">
<!-- ENDIF -->

View File

@@ -1,4 +1,3 @@
<!-- DEFINE $S_IN_PORTAL = 1 -->
<!-- INCLUDE overall_header.html -->
<!-- INCLUDE portal/_block_config.html -->

View File

@@ -53,4 +53,59 @@ class phpbb_functional_portal_no_error_test extends \board3\portal\tests\testfra
$this->assertContains('subsilver', $crawler->text());
self::request('GET', 'app.php/portal?style=2');
}
public function data_portal_all_pages()
{
return array(
array(1),
array(2),
);
}
/**
* @dataProvider data_portal_all_pages
* @dependsOn test_enable_subsilver
*/
public function test_portal_all_pages($style_id)
{
$crawler = self::request('GET', 'index.php?style=' . $style_id);
$this->assertNotContains('Menu', $crawler->text());
$crawler = self::request('GET', 'adm/index.php?i=-board3-portal-acp-portal_module&mode=config&sid=' . $this->sid);
$form = $crawler->selectButton('submit')->form(array(
'config[board3_show_all_pages]' => 1,
'board3_show_all_side' => 0,
));
$crawler = self::submit($form);
$this->assertContainsLang('CONFIG_UPDATED', $crawler->text());
$crawler = self::request('GET', 'index.php?style=' . $style_id);
$this->assertContains('Menu', $crawler->text());
$crawler = self::request('GET', 'adm/index.php?i=-board3-portal-acp-portal_module&mode=config&sid=' . $this->sid);
$form = $crawler->selectButton('submit')->form(array(
'config[board3_show_all_pages]' => 1,
'board3_show_all_side' => 1,
));
$crawler = self::submit($form);
$this->assertContainsLang('CONFIG_UPDATED', $crawler->text());
$crawler = self::request('GET', 'index.php?style=' . $style_id);
$this->assertNotContains('Board Style', $crawler->text());
$this->assertContains('User menu', $crawler->text());
$crawler = self::request('GET', 'adm/index.php?i=-board3-portal-acp-portal_module&mode=config&sid=' . $this->sid);
$form = $crawler->selectButton('submit')->form(array(
'config[board3_show_all_pages]' => 0,
'board3_show_all_side' => 0,
));
$crawler = self::submit($form);
$this->assertContainsLang('CONFIG_UPDATED', $crawler->text());
$crawler = self::request('GET', 'index.php?style=' . $style_id);
$this->assertNotContains('Menu', $crawler->text());
}
}

View File

@@ -36,6 +36,16 @@ class template
}
}
public function assign_vars($vars)
{
$this->data = array_merge($this->data, $vars);
}
public function assign_var($key, $var)
{
$this->data[$key] = $var;
}
public function assert_equals($data, $row)
{
foreach ($data as $key => $value)
@@ -43,4 +53,9 @@ class template
$this->test_case->assertEquals($value, $this->data[$row][$key]);
}
}
public function assert_same($expected, $row)
{
$this->test_case->assertSame($expected, $this->data[$row]);
}
}

View File

@@ -53,4 +53,9 @@ class user extends \PHPUnit_Framework_TestCase
$this->markTestIncomplete('Unable to include language file ' . $file);
}
}
public function lang($var)
{
return $this->lang[$var];
}
}

View File

@@ -0,0 +1,94 @@
<?php
/**
*
* @package testing
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\portal\controller;
class main_test extends \board3\portal\tests\testframework\database_test_case
{
/** @var \board3\portal\controller\main */
protected $controller_main;
/** @var \phpbb\config\config */
protected $config;
/** @var \board3\portal\tests\mock\template */
protected $template;
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/../acp/fixtures/modules.xml');
}
public function setUp()
{
global $phpbb_root_path, $phpEx, $table_prefix, $cache;
parent::setUp();
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new \phpbb_mock_request()
),
new \phpbb\filesystem(),
new \phpbb_mock_request(),
$phpbb_root_path,
$phpEx
);
$cache = new \phpbb\cache\driver\null();
$user = new \board3\portal\tests\mock\user();
$config_table = $table_prefix . 'portal_config';
$modules_table = $table_prefix . 'portal_modules';
$this->template = new \board3\portal\tests\mock\template($this);
$portal_columns = new \board3\portal\portal\columns();
$this->config = new \phpbb\config\config(array('board3_enable' => true));
$modules = array(
'\board3\portal\modules\clock' => new \board3\portal\modules\clock($this->config, $this->template),
);
$portal_helper = new \board3\portal\includes\helper($modules);
$auth = $this->getMock('\phpbb\auth\auth', array('acl_get'));
$auth->expects($this->any())
->method('acl_get')
->with($this->anything())
->will($this->returnValue(true));
$controller_helper = new \board3\portal\controller\helper(
$auth,
$portal_columns,
$this->config,
$this->template,
$user,
$path_helper,
$portal_helper,
$phpbb_root_path,
'.' . $phpEx
);
$this->controller_main = new \board3\portal\controller\main(
$portal_columns,
$this->config,
$controller_helper,
$this->template,
$user,
$path_helper,
$phpbb_root_path,
'.' . $phpEx,
$config_table,
$modules_table
);
}
public function test_display_all_pages()
{
$this->assertNull($this->controller_main->handle(array('left' => 1)));
$this->template->assert_same(true, 'S_PORTAL_ALL');
}
}

View File

@@ -17,6 +17,9 @@ class listener_test extends \phpbb_template_template_test_case
protected $listener;
protected $auth;
/** @var \board3\portal\controller\main */
protected $controller;
static public $hidden_fields = array();
public function setup()
@@ -91,7 +94,12 @@ class listener_test extends \phpbb_template_template_test_case
$this->auth->acl_options['global']['u_view_portal'] = 0;
$this->auth->acl[0][0] = true;
$this->controller = $this->getMockBuilder('\board3\portal\controller\main')
->disableOriginalConstructor()
->getMock();
$this->listener = new \board3\portal\event\listener(
$this->controller,
$this->auth,
$this->config,
$this->controller_helper,