You are here

public function LocalTasksTest::testLocalTaskBlockCache in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php \Drupal\Tests\system\Functional\Menu\LocalTasksTest::testLocalTaskBlockCache()

Tests that local tasks blocks cache is invalidated correctly.

File

core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php, line 258

Class

LocalTasksTest
Tests local tasks derived from router and added/altered via hooks.

Namespace

Drupal\Tests\system\Functional\Menu

Code

public function testLocalTaskBlockCache() {
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalCreateContentType([
    'type' => 'page',
  ]);
  $this
    ->drupalGet('/admin/structure/types/manage/page');

  // Only the Edit task. The block avoids showing a single tab.
  $this
    ->assertNoLocalTasks();

  // Field UI adds the usual Manage fields etc tabs.
  \Drupal::service('module_installer')
    ->install([
    'field_ui',
  ]);
  $this
    ->drupalGet('/admin/structure/types/manage/page');
  $this
    ->assertLocalTasks([
    [
      'entity.node_type.edit_form',
      [
        'node_type' => 'page',
      ],
    ],
    [
      'entity.node.field_ui_fields',
      [
        'node_type' => 'page',
      ],
    ],
    [
      'entity.entity_form_display.node.default',
      [
        'node_type' => 'page',
      ],
    ],
    [
      'entity.entity_view_display.node.default',
      [
        'node_type' => 'page',
      ],
    ],
  ]);
}