protected function WebformAccessBrowserTestBase::setUp in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_access/tests/src/Functional/WebformAccessBrowserTestBase.php \Drupal\Tests\webform_access\Functional\WebformAccessBrowserTestBase::setUp()
Overrides WebformBrowserTestBase::setUp
File
- modules/
webform_access/ tests/ src/ Functional/ WebformAccessBrowserTestBase.php, line 52
Class
- WebformAccessBrowserTestBase
- Test base for webform access.
Namespace
Drupal\Tests\webform_access\FunctionalCode
protected function setUp() {
parent::setUp();
// Create webform nodes.
$this->nodes['contact_01'] = $this
->createWebformNode('contact', [
'title' => 'contact_01',
]);
$this->nodes['contact_02'] = $this
->createWebformNode('contact', [
'title' => 'contact_02',
]);
// Create webform access types and groups.
$types = [
'manager' => [
'administer',
],
'employee' => [
'view_any',
'update_any',
],
'customer' => [
'view_own',
'update_own',
],
];
foreach ($types as $type => $permissions) {
$this->users[$type] = $this
->drupalCreateUser([], $type . '_user');
$values = [
'id' => $type,
'label' => $type . '_type',
];
$webform_access_type = WebformAccessType::create($values);
$webform_access_type
->save();
$this->types[$type] = $webform_access_type;
$values = [
'id' => $type,
'type' => $type,
'label' => $type . '_group',
'permissions' => $permissions,
];
$webform_access_group = WebformAccessGroup::create($values);
$webform_access_group
->addEntityId('node', $this->nodes['contact_01']
->id(), 'webform', 'contact');
$webform_access_group
->save();
$this->groups[$type] = $webform_access_group;
}
}