You are here

public function EntityUsageLayoutBuilderEntityBrowserBlockTest::setUp in Entity Usage 8.4

Same name and namespace in other branches
  1. 8.2 tests/src/FunctionalJavascript/EntityUsageLayoutBuilderEntityBrowserBlockTest.php \Drupal\Tests\entity_usage\FunctionalJavascript\EntityUsageLayoutBuilderEntityBrowserBlockTest::setUp()

Overrides EntityUsageJavascriptTestBase::setUp

File

tests/src/FunctionalJavascript/EntityUsageLayoutBuilderEntityBrowserBlockTest.php, line 43

Class

EntityUsageLayoutBuilderEntityBrowserBlockTest
Tests usage tracking in Layout Builder through Entity Browser Blocks.

Namespace

Drupal\Tests\entity_usage\FunctionalJavascript

Code

public function setUp() {
  parent::setUp();
  $node_type = NodeType::create([
    'type' => 'article',
    'name' => 'article',
  ]);
  $node_type
    ->save();
  LayoutBuilderEntityViewDisplay::create([
    'targetEntityType' => 'node',
    'bundle' => $node_type
      ->id(),
    'mode' => 'default',
    'status' => TRUE,
  ])
    ->enableLayoutBuilder()
    ->setOverridable()
    ->save();
  $this
    ->config('entity_track.settings')
    ->set('track_enabled_entity_types', [
    'node',
  ])
    ->set('track_enabled_plugins', [
    'layout_builder',
    'entity_reference',
  ])
    ->save();
  $this
    ->config('entity_usage.settings')
    ->set('local_task_enabled_entity_types', [
    'node',
  ])
    ->set('track_enabled_target_entity_types', [
    'node',
  ])
    ->save();
  $this
    ->drupalPlaceBlock('local_tasks_block');
  $this
    ->drupalPlaceBlock('page_title_block');

  /** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */
  $router_builder = \Drupal::service('router.builder');
  $router_builder
    ->rebuild();
}