WebformAccessBrowserTestBase.php in Webform 8.5
File
modules/webform_access/tests/src/Functional/WebformAccessBrowserTestBase.php
View source
<?php
namespace Drupal\Tests\webform_access\Functional;
use Drupal\webform_access\Entity\WebformAccessGroup;
use Drupal\webform_access\Entity\WebformAccessType;
use Drupal\Tests\webform_node\Functional\WebformNodeBrowserTestBase;
abstract class WebformAccessBrowserTestBase extends WebformNodeBrowserTestBase {
public static $modules = [
'webform',
'webform_access',
];
protected $nodes = [];
protected $users = [];
protected $types = [];
protected $groups = [];
protected function setUp() {
parent::setUp();
$this->nodes['contact_01'] = $this
->createWebformNode('contact', [
'title' => 'contact_01',
]);
$this->nodes['contact_02'] = $this
->createWebformNode('contact', [
'title' => 'contact_02',
]);
$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;
}
}
}