WebformGroupUserInterfaceTest.php in Webform 8.5
File
modules/webform_group/tests/src/Functional/WebformGroupUserInterfaceTest.php
View source
<?php
namespace Drupal\Tests\webform_group\Functional;
use Drupal\webform\Entity\Webform;
class WebformGroupUserInterfaceTest extends WebformGroupBrowserTestBase {
public static $modules = [
'webform_ui',
];
public function testGroupUserInterfaceAccess() {
$this
->drupalLogin($this->rootUser);
$this
->drupalGet('/admin/structure/webform/manage/contact/access');
$this
->assertRaw('<label for="edit-access-create-group-roles">Group (node) roles</label>');
$this
->assertFieldByName('access[create][group_roles][]');
$this
->drupalPostForm('/admin/structure/webform/manage/contact/access', [
'access[create][group_roles][]' => [
'member',
],
], 'Save');
\Drupal::entityTypeManager()
->getStorage('webform')
->resetCache();
$webform = Webform::load('contact');
$access_rules = $webform
->getAccessRules();
$this
->debug($access_rules);
$this
->assertEqual($access_rules['create']['group_roles'], [
'member',
]);
$this
->drupalGet('/admin/structure/webform/manage/contact/element/name/edit');
$this
->assertFieldByName('properties[access_create_group_roles][]');
$edit = [
'properties[access_create_group_roles][]' => 'member',
];
$this
->drupalPostForm('/admin/structure/webform/manage/contact/element/name/edit', $edit, 'Save');
\Drupal::entityTypeManager()
->getStorage('webform')
->resetCache();
$webform = Webform::load('contact');
$element = $webform
->getElement('name');
$this
->assertEqual($element['#access_create_group_roles'], [
'member',
]);
$this
->drupalGet('/admin/structure/webform/manage/contact/handlers/add/email');
$this
->assertNoCssSelect('select[name="settings[to_mail][select]"] > optgroup[label="Group roles"]');
$this
->assertNoCssSelect('select[name="settings[to_mail][select]"] > optgroup > option[value="[webform_group:role:member]"]');
$this
->assertNoCssSelect('select[name="settings[to_mail][select]"] > optgroup > option[value="[webform_group:owner:mail]"]');
\Drupal::configFactory()
->getEditable('webform_group.settings')
->set('mail.group_roles', [
'member',
])
->set('mail.group_owner', TRUE)
->save();
$this
->drupalGet('/admin/structure/webform/manage/contact/handlers/add/email');
$this
->assertCssSelect('select[name="settings[to_mail][select]"] > optgroup[label="Group roles"]');
$this
->assertCssSelect('select[name="settings[to_mail][select]"] > optgroup > option[value="[webform_group:role:member]"]');
}
}