[ticket/291] Add get_disallowed_forums() method to helper
B3P-291
This commit is contained in:
@@ -72,4 +72,24 @@ class helper
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of disallowed forums
|
||||
*
|
||||
* @param bool $disallow_access Whether the array for disallowing access
|
||||
* should be filled
|
||||
*/
|
||||
public function get_disallowed_forums($disallow_access)
|
||||
{
|
||||
if ($disallow_access == true)
|
||||
{
|
||||
$disallow_access = array_unique(array_keys($this->auth->acl_getf('!f_read', true)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$disallow_access = array();
|
||||
}
|
||||
|
||||
return $disallow_access;
|
||||
}
|
||||
}
|
||||
|
||||
38
tests/unit/includes/fixtures/auth.xml
Normal file
38
tests/unit/includes/fixtures/auth.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_acl_users">
|
||||
<column>user_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>auth_option_id</column>
|
||||
<column>auth_role_id</column>
|
||||
<column>auth_setting</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>16</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_forums">
|
||||
<column>forum_id</column>
|
||||
<column>parent_id</column>
|
||||
<column>forum_parents</column>
|
||||
<column>forum_desc</column>
|
||||
<column>forum_rules</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
||||
57
tests/unit/includes/helper_database_test.php
Normal file
57
tests/unit/includes/helper_database_test.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class board3_includes_helper_database_test extends \board3\portal\tests\testframework\database_test_case
|
||||
{
|
||||
protected $portal_helper;
|
||||
|
||||
protected $modules;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/auth.xml');
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$config = new \phpbb\config\config(array());
|
||||
$this->modules = array(
|
||||
'\board3\portal\modules\link_us' => new \board3\portal\modules\link_us($config, new \board3\portal\tests\mock\template($this), new \board3\portal\tests\mock\user),
|
||||
);
|
||||
$auth = new \phpbb\auth\auth();
|
||||
|
||||
$this->portal_helper = $this->get_portal_helper($auth, $this->modules);
|
||||
}
|
||||
|
||||
protected function get_portal_helper($auth, $modules)
|
||||
{
|
||||
$this->portal_helper = new \board3\portal\includes\helper($auth, $modules);
|
||||
|
||||
return $this->portal_helper;
|
||||
}
|
||||
|
||||
public function data_get_disallowed_forums()
|
||||
{
|
||||
return array(
|
||||
array(array(), false),
|
||||
array(array(0 => 1, 1 => 2), true),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_get_disallowed_forums
|
||||
*/
|
||||
public function test_get_disallowed_forums($expected, $input)
|
||||
{
|
||||
$this->assertEquals($expected, $this->portal_helper->get_disallowed_forums($input));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user