From 620a8622660c5a00f56ce686e397ed09d9cd4039 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 17 Feb 2016 12:56:19 +0100 Subject: [ticket/14315] Add functional tests for permission roles and fix non-js Without JS the settings were not applied due to duplicate input names. PHPBB3-14315 --- phpBB/adm/style/permission_mask.html | 4 +- phpBB/adm/style/tooltip.js | 7 +++ tests/functional/permission_roles_test.php | 86 ++++++++++++++++++++++++++++++ tests/ui/permission_roles_test.php | 4 +- 4 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 tests/functional/permission_roles_test.php diff --git a/phpBB/adm/style/permission_mask.html b/phpBB/adm/style/permission_mask.html index cddcac170f..017d29d832 100644 --- a/phpBB/adm/style/permission_mask.html +++ b/phpBB/adm/style/permission_mask.html @@ -42,7 +42,7 @@ {% if p_mask.f_mask.role_options %}
{% else %} diff --git a/phpBB/adm/style/tooltip.js b/phpBB/adm/style/tooltip.js index b38418876d..65773ae14f 100644 --- a/phpBB/adm/style/tooltip.js +++ b/phpBB/adm/style/tooltip.js @@ -145,6 +145,13 @@ phpbb.prepareRolesDropdown = function () { // Display span and hide select $('.roles-options > span').css('display', 'block'); $('.roles-options > select').hide(); + $('.roles-options > input[type=hidden]').each(function () { + var $this = $(this); + + if ($this.attr('data-name') && !$this.attr('name')) { + $this.attr('name', $this.attr('data-name')); + } + }); // Prepare highlighting of select options and settings update $options.each(function () { diff --git a/tests/functional/permission_roles_test.php b/tests/functional/permission_roles_test.php new file mode 100644 index 0000000000..82d5be68c3 --- /dev/null +++ b/tests/functional/permission_roles_test.php @@ -0,0 +1,86 @@ + +* @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(); + } +} diff --git a/tests/ui/permission_roles_test.php b/tests/ui/permission_roles_test.php index a688680028..fbd0750785 100644 --- a/tests/ui/permission_roles_test.php +++ b/tests/ui/permission_roles_test.php @@ -14,10 +14,10 @@ /** * @group ui */ -class permission_roles_test extends phpbb_ui_test_case +class ui_permission_roles_test extends phpbb_ui_test_case { - public function test_quick_links() + public function test_permission_roles() { $this->login(); $this->admin_login(); -- cgit v1.2.1