diff --git a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php index 12a157d587..77b5d88ad3 100644 --- a/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php +++ b/core/modules/system/tests/src/Functional/Menu/LocalTasksTest.php @@ -3,7 +3,10 @@ namespace Drupal\Tests\system\Functional\Menu; use Drupal\Component\Utility\Html; +use Drupal\Core\Cache\Cache; +use Drupal\Core\Extension\ModuleInstallerInterface; use Drupal\Core\Url; +use Drupal\entity_test\Entity\EntityTestBundle; use Drupal\Tests\BrowserTestBase; /** @@ -18,7 +21,7 @@ class LocalTasksTest extends BrowserTestBase { * * @var string[] */ - public static $modules = ['block', 'menu_test', 'entity_test']; + public static $modules = ['block', 'menu_test', 'entity_test', 'node']; /** * The local tasks block under testing. @@ -253,4 +256,29 @@ public function testLocalTaskBlock() { $this->assertLocalTasks($sub_tasks, 1); } + /** + * Test that local tasks blocks cache is invalidated correctly. + */ + 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']], + ]); + } + }