You are here

protected function InlineEntityFormTest::setUp in Lightning Scheduler 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/InlineEntityFormTest.php, line 32

Class

InlineEntityFormTest
@group lightning_scheduler

Namespace

Drupal\Tests\lightning_scheduler\Functional

Code

protected function setUp() {
  parent::setUp();
  $this
    ->createContentType([
    'type' => 'alpha',
  ]);
  $this
    ->createContentType([
    'type' => 'beta',
  ]);
  $field_storage = FieldStorageConfig::create([
    'type' => 'entity_reference',
    'entity_type' => 'user',
    'settings' => [
      'target_type' => 'node',
    ],
    'field_name' => 'field_inline_entity',
  ]);
  $field_storage
    ->save();
  FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => 'user',
    'settings' => [
      'handler_settings' => [
        'target_bundles' => [
          'alpha' => 'alpha',
        ],
      ],
    ],
    'label' => 'Inline entity',
  ])
    ->save();
  $this
    ->entityGetFormDisplay('user', 'user')
    ->setComponent('field_inline_entity', [
    'type' => 'inline_entity_form_simple',
  ])
    ->save();
  $field_storage = FieldStorageConfig::create([
    'type' => 'entity_reference',
    'entity_type' => 'node',
    'settings' => [
      'target_type' => 'node',
    ],
    'field_name' => 'field_inline_entity',
  ]);
  $field_storage
    ->save();
  FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => 'alpha',
    'settings' => [
      'handler_settings' => [
        'target_bundles' => [
          'beta' => 'beta',
        ],
      ],
    ],
    'label' => 'Inline entity',
  ])
    ->save();
  $this
    ->entityGetFormDisplay('node', 'alpha')
    ->setComponent('field_inline_entity', [
    'type' => 'inline_entity_form_simple',
  ])
    ->save();
  $workflow = $this
    ->createEditorialWorkflow();
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('node', 'alpha');
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('node', 'beta');
  $workflow
    ->save();

  // Inline Entity Form has a problem referencing entities with other than
  // admin users.
  // @see https://www.drupal.org/project/inline_entity_form/issues/2753553
  $this
    ->drupalLogin($this->rootUser);
}