1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
require_once __DIR__ . '/../../phpBB/includes/functions.php';
/**
* @group functional
*/
class functional_permission_roles_test extends phpbb_functional_test_case
{
public function data_permission_roles()
{
return array(
array(
array(0, 14),
array(17, 17),
array(
'role[5][1]' => 14,
)
),
array(
array(14, 14),
array(17, 17),
array(
'role[5][1]' => 0,
)
),
array(
array(0, 14),
array(17, 17)
),
);
}
/**
* @dataProvider data_permission_roles
*/
public function test_permission_roles($admin_roles, $guest_roles, $set_values = array())
{
$this->login();
$this->admin_login();
$this->add_lang('acp/permissions');
$crawler = self::request('GET', 'adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid);
// Select forums
$form = $crawler->filter('form[id=select_victim]')->form();
$form['forum_id']->setValue(array(1,2));
$crawler = self::$client->submit($form);
// Select administrators and guests
$groups_form = $crawler->filter('form[id=groups]')->form();
$groups_form['group_id']->setValue(array(1,5));
$crawler = self::submit($groups_form);
$form = $crawler->filter('form')->form();
$values = $form->getValues();
// Check default settings
$this->assertEquals($admin_roles[0], $values['role[5][1]']);
$this->assertEquals($admin_roles[1], $values['role[5][2]']);
$this->assertEquals($guest_roles[0], $values['role[1][1]']);
$this->assertEquals($guest_roles[1], $values['role[1][2]']);
// Set admin to full access on category
foreach ($set_values as $key => $value)
{
$form[$key]->setValue($value);
}
$form_values = $form->getValues();
$form_values['action[apply_all_permissions]'] = true;
$crawler = self::request('POST', 'adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid, $form_values);
$this->assertContainsLang('AUTH_UPDATED', $crawler->text());
$this->logout();
}
}
|