mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-05 23:25:30 +02:00
[ticket/10758] Test moderator and admin permissions.
PHPBB3-10758
This commit is contained in:
parent
ac3e69cb08
commit
3327a4676c
@ -12,19 +12,27 @@
|
|||||||
*/
|
*/
|
||||||
class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
|
class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
|
||||||
{
|
{
|
||||||
public function test_set_permission()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
$this->login();
|
$this->login();
|
||||||
$this->admin_login();
|
$this->admin_login();
|
||||||
$this->add_lang('acp/permissions');
|
$this->add_lang('acp/permissions');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_permissions_tab()
|
||||||
|
{
|
||||||
// Permissions tab
|
// Permissions tab
|
||||||
// XXX hardcoded id
|
// XXX hardcoded id
|
||||||
$crawler = $this->request('GET', 'adm/index.php?i=16&sid=' . $this->sid);
|
$crawler = $this->request('GET', 'adm/index.php?i=16&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
$this->assert_response_success();
|
||||||
// these language strings are html
|
// these language strings are html
|
||||||
$this->assertContains($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->client->getResponse()->getContent());
|
$this->assertContains($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->client->getResponse()->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_select_user()
|
||||||
|
{
|
||||||
// User permissions
|
// User permissions
|
||||||
$crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
|
$crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
|
||||||
$this->assert_response_success();
|
$this->assert_response_success();
|
||||||
@ -37,6 +45,53 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
|
|||||||
$crawler = $this->client->submit($form);
|
$crawler = $this->client->submit($form);
|
||||||
$this->assert_response_success();
|
$this->assert_response_success();
|
||||||
$this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
|
$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
|
// XXX globals for phpbb_auth, refactor it later
|
||||||
global $db, $cache;
|
global $db, $cache;
|
||||||
@ -47,15 +102,15 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
|
|||||||
// XXX hardcoded id
|
// XXX hardcoded id
|
||||||
$user_data = $auth->obtain_user_data(2);
|
$user_data = $auth->obtain_user_data(2);
|
||||||
$auth->acl($user_data);
|
$auth->acl($user_data);
|
||||||
$this->assertEquals(1, $auth->acl_get('u_hideonline'));
|
$this->assertEquals(1, $auth->acl_get($permission));
|
||||||
|
|
||||||
// Set u_hideonline to never
|
// Set u_hideonline to never
|
||||||
$form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form();
|
$form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form();
|
||||||
// initially it should be a yes
|
// initially it should be a yes
|
||||||
$values = $form->getValues();
|
$values = $form->getValues();
|
||||||
$this->assertEquals(1, $values['setting[2][0][u_hideonline]']);
|
$this->assertEquals(1, $values["setting[$object_id][0][$permission]"]);
|
||||||
// set to never
|
// set to never
|
||||||
$data = array('setting[2][0][u_hideonline]' => '0');
|
$data = array("setting[$object_id][0][$permission]" => '0');
|
||||||
$form->setValues($data);
|
$form->setValues($data);
|
||||||
$crawler = $this->client->submit($form);
|
$crawler = $this->client->submit($form);
|
||||||
$this->assert_response_success();
|
$this->assert_response_success();
|
||||||
@ -66,6 +121,6 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
|
|||||||
// XXX hardcoded id
|
// XXX hardcoded id
|
||||||
$user_data = $auth->obtain_user_data(2);
|
$user_data = $auth->obtain_user_data(2);
|
||||||
$auth->acl($user_data);
|
$auth->acl($user_data);
|
||||||
$this->assertEquals(0, $auth->acl_get('u_hideonline'));
|
$this->assertEquals(0, $auth->acl_get($permission));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user