aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/acp_permissions_test.php
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-12-15 17:26:48 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-12-19 21:50:35 -0500
commit3327a4676ce2f894881485aa8f5a5c40c9ea260e (patch)
treed4237dc9713b579c94760f461c70ce0e0b87fd4e /tests/functional/acp_permissions_test.php
parentac3e69cb0856779016dcc02060e8e30b804fcd67 (diff)
downloadforums-3327a4676ce2f894881485aa8f5a5c40c9ea260e.tar
forums-3327a4676ce2f894881485aa8f5a5c40c9ea260e.tar.gz
forums-3327a4676ce2f894881485aa8f5a5c40c9ea260e.tar.bz2
forums-3327a4676ce2f894881485aa8f5a5c40c9ea260e.tar.xz
forums-3327a4676ce2f894881485aa8f5a5c40c9ea260e.zip
[ticket/10758] Test moderator and admin permissions.
PHPBB3-10758
Diffstat (limited to 'tests/functional/acp_permissions_test.php')
-rw-r--r--tests/functional/acp_permissions_test.php65
1 files changed, 60 insertions, 5 deletions
diff --git a/tests/functional/acp_permissions_test.php b/tests/functional/acp_permissions_test.php
index 0fa7898963..511306ac84 100644
--- a/tests/functional/acp_permissions_test.php
+++ b/tests/functional/acp_permissions_test.php
@@ -12,19 +12,27 @@
*/
class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
{
- public function test_set_permission()
+ public function setUp()
{
+ parent::setUp();
+
$this->login();
$this->admin_login();
$this->add_lang('acp/permissions');
+ }
+ public function test_permissions_tab()
+ {
// Permissions tab
// XXX hardcoded id
$crawler = $this->request('GET', 'adm/index.php?i=16&sid=' . $this->sid);
$this->assert_response_success();
// these language strings are html
$this->assertContains($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->client->getResponse()->getContent());
+ }
+ public function test_select_user()
+ {
// User permissions
$crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
$this->assert_response_success();
@@ -37,6 +45,53 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
$crawler = $this->client->submit($form);
$this->assert_response_success();
$this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
+ }
+
+ public function permissions_data()
+ {
+ return array(
+ // description
+ // permission type
+ // permission name
+ // mode
+ // object name
+ // object id
+ array(
+ 'user permission',
+ 'u_',
+ 'u_hideonline',
+ 'setting_user_global',
+ 'user_id',
+ 2,
+ ),
+ array(
+ 'moderator permission',
+ 'm_',
+ 'm_ban',
+ 'setting_mod_global',
+ 'group_id',
+ 4,
+ ),
+ array(
+ 'admin permission',
+ 'a_',
+ 'a_forum',
+ 'setting_admin_global',
+ 'group_id',
+ 5,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider permissions_data
+ */
+ public function test_change_permission($description, $permission_type, $permission, $mode, $object_name, $object_id)
+ {
+ // Get the form
+ $crawler = $this->request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=$mode&${object_name}[0]=$object_id&type=$permission_type&sid=" . $this->sid);
+ $this->assert_response_success();
+ $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
// XXX globals for phpbb_auth, refactor it later
global $db, $cache;
@@ -47,15 +102,15 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
// XXX hardcoded id
$user_data = $auth->obtain_user_data(2);
$auth->acl($user_data);
- $this->assertEquals(1, $auth->acl_get('u_hideonline'));
+ $this->assertEquals(1, $auth->acl_get($permission));
// Set u_hideonline to never
$form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form();
// initially it should be a yes
$values = $form->getValues();
- $this->assertEquals(1, $values['setting[2][0][u_hideonline]']);
+ $this->assertEquals(1, $values["setting[$object_id][0][$permission]"]);
// set to never
- $data = array('setting[2][0][u_hideonline]' => '0');
+ $data = array("setting[$object_id][0][$permission]" => '0');
$form->setValues($data);
$crawler = $this->client->submit($form);
$this->assert_response_success();
@@ -66,6 +121,6 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
// XXX hardcoded id
$user_data = $auth->obtain_user_data(2);
$auth->acl($user_data);
- $this->assertEquals(0, $auth->acl_get('u_hideonline'));
+ $this->assertEquals(0, $auth->acl_get($permission));
}
}