diff options
author | Marc Alexander <admin@m-a-styles.de> | 2016-02-16 22:46:03 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2016-02-16 22:46:03 +0100 |
commit | d429fd03bfaf648a685519dfc7383152611a08e7 (patch) | |
tree | 1605a0b10ed4380e59d11304853e11d2ad158474 /tests/ui/permission_roles_test.php | |
parent | 845639ba371e0aacb60f760851c9c6b1cf6e9bd6 (diff) | |
download | forums-d429fd03bfaf648a685519dfc7383152611a08e7.tar forums-d429fd03bfaf648a685519dfc7383152611a08e7.tar.gz forums-d429fd03bfaf648a685519dfc7383152611a08e7.tar.bz2 forums-d429fd03bfaf648a685519dfc7383152611a08e7.tar.xz forums-d429fd03bfaf648a685519dfc7383152611a08e7.zip |
[ticket/14315] Add tests for setting permission roles using javascript
PHPBB3-14315
Diffstat (limited to 'tests/ui/permission_roles_test.php')
-rw-r--r-- | tests/ui/permission_roles_test.php | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/tests/ui/permission_roles_test.php b/tests/ui/permission_roles_test.php new file mode 100644 index 0000000000..a688680028 --- /dev/null +++ b/tests/ui/permission_roles_test.php @@ -0,0 +1,89 @@ +<?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. +* +*/ + +/** +* @group ui +*/ +class permission_roles_test extends phpbb_ui_test_case +{ + + public function test_quick_links() + { + $this->login(); + $this->admin_login(); + $this->add_lang('acp/permissions'); + $this->visit('adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid); + + // Select forums + $elements = self::find_element('cssSelector', 'select[id=forum]') + ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); + foreach ($elements as $element) + { + $element->click(); + } + self::find_element('cssSelector', 'form[id=select_victim]') + ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=submit]')) + ->click(); + + // Select administrators and guests + $groups_form = self::find_element('cssSelector', 'form[id=groups]'); + $elements = $groups_form + ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('select')) + ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); + + foreach ($elements as $element) + { + if ($element->getText() === 'Administrators' || $element->getText() === 'Guests') + { + $element->click(); + } + } + $groups_form->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[name=submit_edit_options]'))->click(); + + $first_fieldset = self::find_element('cssSelector', '#perm11'); + $this->assertEquals('none', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + $first_fieldset + ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle')) + ->click(); + $this->assertEquals('block', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + $lis = $first_fieldset + ->findElements(\Facebook\WebDriver\WebDriverBy::cssSelector('ul > li')); + + foreach ($lis as $li) + { + if ($li->getAttribute('data-id') == 18) + { + $li->click(); + + break; + } + } + $this->assertEquals('none', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + $this->assertEquals(18, $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); + $this->assertEquals($this->lang('ROLE_FORUM_LIMITED'), $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); + + // Check that admin settings didn't get changed + $second_fieldset = self::find_element('cssSelector', '#perm10'); + $this->assertEquals('none', $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + // Full access = 14 + $this->assertEquals(14, $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); + $this->assertEquals($this->lang('ROLE_FORUM_FULL'), $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); + + // Check that category settings were not modified + $category_fieldset = self::find_element('cssSelector', '#perm00'); + $this->assertEquals('none', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); + // No settings + $this->assertEquals('', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); + $this->assertEquals($this->lang('NO_ROLE_ASSIGNED'), $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); + } +} |