[ticket/354] Do not show portal link if user is not authed to see it

B3P-354
This commit is contained in:
Marc Alexander
2014-08-25 00:12:46 +02:00
parent 917eb48e07
commit f737a7d683
3 changed files with 44 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ class listener_test extends \phpbb_template_template_test_case
{
/** @var \board3\portal\event\listener */
protected $listener;
protected $auth;
static public $hidden_fields = array();
@@ -32,6 +33,19 @@ class listener_test extends \phpbb_template_template_test_case
public function setup_listener()
{
global $cache, $db;
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists', 'put', 'obtain_attach_extensions'));
$cache->expects($this->any())
->method('obtain_word_list')
->with()
->will($this->returnValue(array()));
$cache->expects($this->any())
->method('get')
->with($this->anything())
->will($this->returnValue(false));
$db = $this->getMock('\phpbb\db\driver\driver_interface');
$this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$this->user->expects($this->any())
->method('lang')
@@ -61,7 +75,17 @@ class listener_test extends \phpbb_template_template_test_case
$this->php_ext
);
$this->auth = new \phpbb\auth\auth();
$userdata = array(
'user_id' => 2,
);
$this->auth->acl($userdata);
// Pretend to allow downloads
$this->auth->acl_options['global']['u_view_portal'] = 0;
$this->auth->acl[0][0] = true;
$this->listener = new \board3\portal\event\listener(
$this->auth,
$this->controller_helper,
$this->path_helper,
$this->template,
@@ -124,6 +148,13 @@ class listener_test extends \phpbb_template_template_test_case
$result = $this->phpbb_dispatcher->trigger_event('core.page_header', compact($vars));
$this->assertEmpty($result);
// Make sure user shouldn't see link
unset($this->auth->cache[0]['u_view_portal']);
$this->auth->acl[0][0] = false;
$result = $this->phpbb_dispatcher->trigger_event('core.page_header', compact($vars));
$this->assertEmpty($result);
}
public function test_load_portal_language()