function LayoutBuilderCompatibilityTestBase::setUp

Same name and namespace in other branches
  1. 8.9.x core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php \Drupal\Tests\layout_builder\Kernel\LayoutBuilderCompatibilityTestBase::setUp()
  2. 10 core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php \Drupal\Tests\layout_builder\Kernel\LayoutBuilderCompatibilityTestBase::setUp()
  3. 11.x core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php \Drupal\Tests\layout_builder\Kernel\LayoutBuilderCompatibilityTestBase::setUp()

Overrides EntityKernelTestBase::setUp

1 call to LayoutBuilderCompatibilityTestBase::setUp()
LayoutBuilderFieldLayoutCompatibilityTest::setUp in core/modules/layout_builder/tests/src/Kernel/LayoutBuilderFieldLayoutCompatibilityTest.php
1 method overrides LayoutBuilderCompatibilityTestBase::setUp()
LayoutBuilderFieldLayoutCompatibilityTest::setUp in core/modules/layout_builder/tests/src/Kernel/LayoutBuilderFieldLayoutCompatibilityTest.php

File

core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php, line 40

Class

LayoutBuilderCompatibilityTestBase
Tests Layout Builder's compatibility with existing systems.

Namespace

Drupal\Tests\layout_builder\Kernel

Code

protected function setUp() {
    parent::setUp();
    $this->installEntitySchema('entity_test_base_field_display');
    $this->installConfig([
        'filter',
    ]);
    // Set up a non-admin user that is allowed to view test entities.
    \Drupal::currentUser()->setAccount($this->createUser([
        'uid' => 2,
    ], [
        'view test entity',
    ]));
    \Drupal::service('theme_installer')->install([
        'starterkit_theme',
    ]);
    $this->config('system.theme')
        ->set('default', 'starterkit_theme')
        ->save();
    $field_storage = FieldStorageConfig::create([
        'entity_type' => 'entity_test_base_field_display',
        'field_name' => 'test_field_display_configurable',
        'type' => 'boolean',
    ]);
    $field_storage->save();
    FieldConfig::create([
        'field_storage' => $field_storage,
        'bundle' => 'entity_test_base_field_display',
        'label' => 'FieldConfig with configurable display',
    ])->save();
    $this->display = EntityViewDisplay::create([
        'targetEntityType' => 'entity_test_base_field_display',
        'bundle' => 'entity_test_base_field_display',
        'mode' => 'default',
        'status' => TRUE,
    ]);
    $this->display
        ->setComponent('test_field_display_configurable', [
        'weight' => 5,
    ])
        ->save();
    // Create an entity with fields that are configurable and non-configurable.
    $entity_storage = $this->container
        ->get('entity_type.manager')
        ->getStorage('entity_test_base_field_display');
    // @todo Remove langcode workarounds after resolving
    //   https://www.drupal.org/node/2915034.
    $this->entity = $entity_storage->createWithSampleValues('entity_test_base_field_display', [
        'langcode' => 'en',
        'langcode_default' => TRUE,
    ]);
    $this->entity
        ->save();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.