protected function WorkbenchEmailTestTrait::setUpEmailFieldForNodeBundle in Workbench Email 8
Same name and namespace in other branches
- 2.x tests/src/Traits/WorkbenchEmailTestTrait.php \Drupal\Tests\workbench_email\Traits\WorkbenchEmailTestTrait::setUpEmailFieldForNodeBundle()
Adds an email field to a node bundle.
Parameters
string $bundle: (optional) Bundle name. Defaults to 'test'.
2 calls to WorkbenchEmailTestTrait::setUpEmailFieldForNodeBundle()
- ConfigDependenciesTest::setUp in tests/
src/ Kernel/ ConfigDependenciesTest.php - RecipientTypePluginsTest::setUp in tests/
src/ Kernel/ RecipientTypePluginsTest.php
File
- tests/
src/ Traits/ WorkbenchEmailTestTrait.php, line 36
Class
- WorkbenchEmailTestTrait
- Contains helper classes for tests to set up various configuration.
Namespace
Drupal\Tests\workbench_email\TraitsCode
protected function setUpEmailFieldForNodeBundle($bundle = 'test') {
// Add an email field notify to the bundle.
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(sprintf('node.%s.default', $bundle)))) {
$entity_form_display = EntityFormDisplay::create([
'targetEntityType' => 'node',
'bundle' => $bundle,
'mode' => 'default',
'status' => TRUE,
]);
}
$entity_form_display
->setComponent('field_email', [
'type' => 'email_default',
])
->save();
}