You are here

protected function EmailItemTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Kernel/Email/EmailItemTest.php \Drupal\Tests\field\Kernel\Email\EmailItemTest::setUp()
  2. 9 core/modules/field/tests/src/Kernel/Email/EmailItemTest.php \Drupal\Tests\field\Kernel\Email\EmailItemTest::setUp()

File

core/modules/field/tests/src/Kernel/Email/EmailItemTest.php, line 19

Class

EmailItemTest
Tests the new entity API for the email field type.

Namespace

Drupal\Tests\field\Kernel\Email

Code

protected function setUp() : void {
  parent::setUp();

  // Create an email field storage and field for validation.
  FieldStorageConfig::create([
    'field_name' => 'field_email',
    'entity_type' => 'entity_test',
    'type' => 'email',
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => 'entity_test',
    'field_name' => 'field_email',
    'bundle' => 'entity_test',
  ])
    ->save();

  // Create a form display for the default form mode.
  \Drupal::service('entity_display.repository')
    ->getFormDisplay('entity_test', 'entity_test')
    ->setComponent('field_email', [
    'type' => 'email_default',
  ])
    ->save();
}