You are here

public function TokenFieldUiTest::setUp in Token 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/TokenFieldUiTest.php, line 34

Class

TokenFieldUiTest
Tests field ui.

Namespace

Drupal\Tests\token\Functional

Code

public function setUp($modules = []) {
  parent::setUp();
  $this->adminUser = $this
    ->drupalCreateUser([
    'administer content types',
    'administer node fields',
  ]);
  $this
    ->drupalLogin($this->adminUser);
  $node_type = NodeType::create([
    'type' => 'article',
    'name' => 'Article',
    'description' => "Use <em>articles</em> for time-sensitive content like news, press releases or blog posts.",
  ]);
  $node_type
    ->save();
  FieldStorageConfig::create([
    'field_name' => 'field_body',
    'entity_type' => 'node',
    'type' => 'text_with_summary',
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_body',
    'label' => 'Body',
    'entity_type' => 'node',
    'bundle' => 'article',
  ])
    ->save();
  FieldStorageConfig::create([
    'field_name' => 'field_image',
    'entity_type' => 'node',
    'type' => 'image',
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_image',
    'label' => 'Image',
    'entity_type' => 'node',
    'bundle' => 'article',
  ])
    ->save();
  FieldStorageConfig::create([
    'field_name' => 'field_image_2',
    'entity_type' => 'node',
    'type' => 'image',
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_image_2',
    'label' => 'Image 2',
    'entity_type' => 'node',
    'bundle' => 'article',
  ])
    ->save();
  FieldStorageConfig::create([
    'field_name' => 'multivalued_field_image',
    'entity_type' => 'node',
    'type' => 'image',
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'multivalued_field_image',
    'label' => 'Multivalued field image',
    'entity_type' => 'node',
    'bundle' => 'article',
  ])
    ->save();
  \Drupal::service('entity_display.repository')
    ->getFormDisplay('node', 'article', 'default')
    ->setComponent('field_body', [
    'type' => 'text_textarea_with_summary',
    'settings' => [
      'rows' => '9',
      'summary_rows' => '3',
    ],
    'weight' => 5,
  ])
    ->save();
}