protected function MailWithTypeItemTest::setUp in CRM Core 8.2
Overrides KernelTestBase::setUp
File
- modules/
crm_core_contact/ tests/ src/ Kernel/ MailWithTypeItemTest.php, line 51
Class
- MailWithTypeItemTest
- Tests the 'email_with_type' field type.
Namespace
Drupal\Tests\crm_core_contact\KernelCode
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('entity_test');
$this
->installEntitySchema('user');
// Create a 'mail_with_type' field storage and field for validation.
FieldStorageConfig::create([
'field_name' => 'field_mail_with_type',
'entity_type' => 'entity_test',
'type' => 'email_with_type',
'settings' => [
'email_types' => [
'home' => 'Home',
'work' => 'Work',
],
],
])
->save();
FieldConfig::create([
'entity_type' => 'entity_test',
'field_name' => 'field_mail_with_type',
'bundle' => 'entity_test',
'label' => 'Email with type',
])
->save();
// Create a form display for the default form mode.
$this->formDisplay = EntityFormDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
'status' => TRUE,
]);
$this->formDisplay
->setComponent('field_mail_with_type', [
'type' => 'email_with_type',
])
->save();
// Create view display for the default view mode.
$this->viewDisplay = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
'content' => [],
]);
$this->viewDisplay
->setComponent('field_mail_with_type', [
'type' => 'email_with_type',
])
->save();
}