public function WorkbenchEmailTestBase::setUp in Workbench Email 8
Same name and namespace in other branches
- 2.x tests/src/Functional/WorkbenchEmailTestBase.php \Drupal\Tests\workbench_email\Functional\WorkbenchEmailTestBase::setUp()
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ WorkbenchEmailTestBase.php, line 114
Class
- WorkbenchEmailTestBase
- Defines a base class for workbench email tests.
Namespace
Drupal\Tests\workbench_email\FunctionalCode
public function setUp() {
parent::setUp();
// Place some blocks.
$this
->placeBlock('local_tasks_block', [
'id' => 'tabs_block',
]);
$this
->placeBlock('page_title_block');
$this
->placeBlock('local_actions_block', [
'id' => 'actions_block',
]);
// Create two node-types and make them moderated.
$this->nodeType = NodeType::create([
'type' => 'test',
'name' => 'Test',
]);
$this
->setupModerationForNodeType($this->nodeType);
$this->nodeType = NodeType::create([
'type' => 'another',
'name' => 'Another Test',
]);
$this
->setupModerationForNodeType($this->nodeType);
// Create an approver role and two users.
$this->approverRole = $this
->drupalCreateRole($this
->getApproverPermissions(), 'approver', 'Approver');
$this->approver1 = $this
->drupalCreateUser();
$this->approver1
->addRole('approver');
$this->approver1
->save();
$this->approver2 = $this
->drupalCreateUser();
$this->approver2
->addRole('approver');
$this->approver2
->save();
$this->approver3 = $this
->drupalCreateUser();
$this->approver3
->addRole('approver');
$this->approver3
->block();
$this->approver3
->save();
$this->approver4 = $this
->drupalCreateUser();
$this->approver4
->addRole('approver');
$this->approver4
->setEmail(NULL);
$this->approver4
->save();
// Create a editor role and user.
$this->editorRole = $this
->drupalCreateRole($this
->getEditorPermissions(), 'editor', 'Editor');
$this->editor = $this
->drupalCreateUser();
$this->editor
->addRole('editor');
$this->editor
->save();
// Create an admin user.
$this->admin = $this
->drupalCreateUser($this
->getAdminPermissions());
// Add an email field notify to the node-type.
FieldStorageConfig::create([
'cardinality' => 1,
'entity_type' => 'node',
'field_name' => 'field_email',
'type' => 'email',
])
->save();
FieldConfig::create([
'field_name' => 'field_email',
'bundle' => 'test',
'label' => 'Notify',
'entity_type' => 'node',
])
->save();
if (!($entity_form_display = EntityFormDisplay::load('node.test.default'))) {
$entity_form_display = EntityFormDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'test',
'mode' => 'default',
'status' => TRUE,
]);
}
$entity_form_display
->setComponent('field_email', [
'type' => 'email_default',
])
->save();
}