protected function MessageNotifyTest::attachRenderedFields in Message Notify 8
Helper function to attach rendred fields.
See also
MessageNotifyTest::testPostSendRenderedField()
1 call to MessageNotifyTest::attachRenderedFields()
- MessageNotifyTest::testPostSendRenderedField in tests/
src/ Kernel/ MessageNotifyTest.php - Test populating the rednered output to fields.
File
- tests/
src/ Kernel/ MessageNotifyTest.php, line 191
Class
- MessageNotifyTest
- Test the Message notifier plugins handling.
Namespace
Drupal\Tests\message_notify\KernelCode
protected function attachRenderedFields() {
foreach ([
'rendered_foo',
'rendered_bar',
'rendered_baz',
] as $field_name) {
// Use formatted text for `baz`, plain for others.
$config = [
'field_name' => $field_name,
'type' => 'string_long',
'entity_type' => 'message',
];
if ($field_name == 'rendered_baz') {
$config['type'] = 'text_long';
}
$field_storage = FieldStorageConfig::create($config);
$field_storage
->save();
$field = FieldConfig::create([
'field_name' => $field_name,
'bundle' => $this->messageTemplate
->id(),
'entity_type' => 'message',
'label' => $field_name,
]);
$field
->save();
}
}