protected function EasyEmailTestBase::addUserField in Easy Email 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/EasyEmailTestBase.php \Drupal\Tests\easy_email\Functional\EasyEmailTestBase::addUserField()
Parameters
\Drupal\easy_email\Entity\EasyEmailTypeInterface $easy_email_type:
string $field_name:
string $label:
24 calls to EasyEmailTestBase::addUserField()
- EasyEmailSendTest::testSaveWithoutSend in tests/
src/ Functional/ EasyEmailSendTest.php - Tests email saving without sending.
- EasyEmailSendTest::testSendDuplicateCheck in tests/
src/ Functional/ EasyEmailSendTest.php - Tests email sending with a unique key to prevent duplicates
- EasyEmailSendTest::testSendHtmlAndPlainText in tests/
src/ Functional/ EasyEmailSendTest.php - Tests sending email with an HTML and Plain Text version
- EasyEmailSendTest::testSendHtmlGeneratePlainText in tests/
src/ Functional/ EasyEmailSendTest.php - Tests email sending with plain text version generated from HTML version
- EasyEmailSendTest::testSendHtmlOnly in tests/
src/ Functional/ EasyEmailSendTest.php - Tests email sending with HTML version only
File
- tests/
src/ Functional/ EasyEmailTestBase.php, line 165
Class
- EasyEmailTestBase
- Class EasyEmailTestBase
Namespace
Drupal\Tests\easy_email\FunctionalCode
protected function addUserField(EasyEmailTypeInterface $easy_email_type, $field_name = 'field_user', $label = 'User') {
$field_definition = BaseFieldDefinition::create('entity_reference')
->setTargetEntityTypeId('easy_email')
->setTargetBundle($easy_email_type
->id())
->setName($field_name)
->setLabel($label)
->setRevisionable(TRUE)
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
->setRequired(FALSE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
try {
easy_email_create_field($field_definition, FALSE);
} catch (\RuntimeException $e) {
// In this case, field already exists from installation
} catch (EntityStorageException $e) {
// In this case, field already exists from installation
}
}