diff --git a/core/modules/language/tests/src/Kernel/LanguageDisplayConfigurationAfterUninstallTest.php b/core/modules/language/tests/src/Kernel/LanguageDisplayConfigurationAfterUninstallTest.php new file mode 100644 index 0000000000..b253bbd2e0 --- /dev/null +++ b/core/modules/language/tests/src/Kernel/LanguageDisplayConfigurationAfterUninstallTest.php @@ -0,0 +1,114 @@ +installSchema('user', ['users_data']); + + // Create 'default' view-display. + $display = EntityViewDisplay::create([ + 'targetEntityType' => 'entity_test', + 'bundle' => 'entity_test', + 'mode' => 'default', + 'status' => TRUE, + ]); + $display->save(); + + // Create 'default' form-display. + $display = EntityFormDisplay::create([ + 'targetEntityType' => 'entity_test', + 'bundle' => 'entity_test', + 'mode' => 'default', + 'status' => TRUE, + ]); + $display->save(); + + // Create a view-mode 'manual', create view-display that uses it. + EntityViewMode::create([ + 'id' => 'entity_test.manual', + 'targetEntityType' => 'entity_test', + 'status' => TRUE, + 'enabled' => TRUE, + ])->save(); + $display = EntityViewDisplay::create([ + 'targetEntityType' => 'entity_test', + 'bundle' => 'entity_test', + 'mode' => 'manual', + 'status' => TRUE, + ]); + $display->save(); + + // Create a new form-mode 'manual', create form-display that uses it. + EntityFormMode::create([ + 'id' => 'entity_test.manual', + 'targetEntityType' => 'entity_test', + 'status' => TRUE, + 'enabled' => TRUE, + ])->save(); + $display = EntityFormDisplay::create([ + 'targetEntityType' => 'entity_test', + 'bundle' => 'entity_test', + 'mode' => 'manual', + 'status' => TRUE, + ]); + $display->save(); + + } + + /** + * Tests display configuration after uninstalling Language module. + */ + public function testConfigAfterUninstall() { + $default_view_display = 'core.entity_view_display.entity_test.entity_test.default'; + $default_form_display = 'core.entity_view_display.entity_test.entity_test.default'; + $manual_view_display = 'core.entity_view_display.entity_test.entity_test.manual'; + $manual_form_display = 'core.entity_view_display.entity_test.entity_test.manual'; + + // 1. Validate that "langcode" key is there. + $this->assertArrayHasKey('langcode', \Drupal::config($default_view_display)->get('hidden')); + $this->assertArrayHasKey('langcode', \Drupal::config($default_form_display)->get('hidden')); + $this->assertArrayHasKey('langcode', \Drupal::config($manual_view_display)->get('hidden')); + $this->assertArrayHasKey('langcode', \Drupal::config($manual_form_display)->get('hidden')); + + // 2. Uninstall language module. + \Drupal::service('module_installer')->uninstall(['language']); + + // 3. Test that "langcode" key is removed from field config. + $this->assertArrayNotHasKey('langcode', \Drupal::config($default_view_display)->get('hidden')); + $this->assertArrayNotHasKey('langcode', \Drupal::config($default_form_display)->get('hidden')); + $this->assertArrayNotHasKey('langcode', \Drupal::config($manual_view_display)->get('hidden')); + $this->assertArrayNotHasKey('langcode', \Drupal::config($manual_form_display)->get('hidden')); + + } + +}