diff --git a/core/modules/entity/src/Tests/EntityDisplayModeTest.php b/core/modules/entity/src/Tests/EntityDisplayModeTest.php
deleted file mode 100644
index 16c55f5..0000000
--- a/core/modules/entity/src/Tests/EntityDisplayModeTest.php
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\entity\Tests\EntityDisplayModeTest.
- */
-
-namespace Drupal\entity\Tests;
-
-use Drupal\simpletest\WebTestBase;
-
-/**
- * Tests the entity display mode configuration entities.
- */
-class EntityDisplayModeTest extends WebTestBase {
-
-  /**
-   * Modules to enable.
-   *
-   * @var array
-   */
-  public static $modules = array('entity_test');
-
-  public static function getInfo() {
-    return array(
-      'name' => 'Entity display modes UI',
-      'description' => 'Tests the entity display modes UI.',
-      'group' => 'Entity',
-    );
-  }
-
-  /**
-   * Tests the EntityViewMode user interface.
-   */
-  public function testEntityViewModeUI() {
-    // Test the listing page.
-    $this->drupalGet('admin/structure/display-modes/view');
-    $this->assertResponse(403);
-    $this->drupalLogin($this->drupalCreateUser(array('administer display modes')));
-    $this->drupalGet('admin/structure/display-modes/view');
-    $this->assertResponse(200);
-    $this->assertText(t('Add new view mode'));
-    $this->assertLinkByHref('admin/structure/display-modes/view/add');
-
-    $this->drupalGet('admin/structure/display-modes/view/add/entity_test_mulrev');
-    $this->assertResponse(404);
-
-    $this->drupalGet('admin/structure/display-modes/view/add');
-    $this->assertNoLink(t('Test entity - revisions and data table'), 'An entity type with no view builder cannot have view modes.');
-
-    // Test adding a view mode including dots in machine_name.
-    $this->clickLink(t('Test entity'));
-    $edit = array(
-      'id' => strtolower($this->randomName()) . '.' . strtolower($this->randomName()),
-      'label' => $this->randomString(),
-    );
-    $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
-
-    // Test adding a view mode.
-    $edit = array(
-      'id' => strtolower($this->randomName()),
-      'label' => $this->randomString(),
-    );
-    $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('Saved the %label view mode.', array('%label' => $edit['label'])));
-
-    // Test editing the view mode.
-    $this->drupalGet('admin/structure/display-modes/view/manage/entity_test.' . $edit['id']);
-
-    // Test deleting the view mode.
-    $this->clickLink(t('Delete'));
-    $this->assertRaw(t('Are you sure you want to delete the %label view mode?', array('%label' => $edit['label'])));
-    $this->drupalPostForm(NULL, NULL, t('Delete'));
-    $this->assertRaw(t('Deleted the %label view mode.', array('%label' => $edit['label'])));
-  }
-
-  /**
-   * Tests the EntityFormMode user interface.
-   */
-  public function testEntityFormModeUI() {
-    // Test the listing page.
-    $this->drupalGet('admin/structure/display-modes/form');
-    $this->assertResponse(403);
-    $this->drupalLogin($this->drupalCreateUser(array('administer display modes')));
-    $this->drupalGet('admin/structure/display-modes/form');
-    $this->assertResponse(200);
-    $this->assertText(t('Add new form mode'));
-    $this->assertLinkByHref('admin/structure/display-modes/form/add');
-
-    $this->drupalGet('admin/structure/display-modes/form/add/entity_test_no_label');
-    $this->assertResponse(404);
-
-    $this->drupalGet('admin/structure/display-modes/form/add');
-    $this->assertNoLink(t('Entity Test without label'), 'An entity type with no form cannot have form modes.');
-
-    // Test adding a view mode including dots in machine_name.
-    $this->clickLink(t('Test entity'));
-    $edit = array(
-      'id' => strtolower($this->randomName()) . '.' . strtolower($this->randomName()),
-      'label' => $this->randomString(),
-    );
-    $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
-
-    // Test adding a form mode.
-    $edit = array(
-      'id' => strtolower($this->randomName()),
-      'label' => $this->randomString(),
-    );
-    $this->drupalPostForm(NULL, $edit, t('Save'));
-    $this->assertRaw(t('Saved the %label form mode.', array('%label' => $edit['label'])));
-
-    // Test editing the form mode.
-    $this->drupalGet('admin/structure/display-modes/form/manage/entity_test.' . $edit['id']);
-
-    // Test deleting the form mode.
-    $this->clickLink(t('Delete'));
-    $this->assertRaw(t('Are you sure you want to delete the %label form mode?', array('%label' => $edit['label'])));
-    $this->drupalPostForm(NULL, NULL, t('Delete'));
-    $this->assertRaw(t('Deleted the %label form mode.', array('%label' => $edit['label'])));
-  }
-
-}
diff --git a/core/modules/entity/src/Tests/EntityDisplayTest.php b/core/modules/entity/src/Tests/EntityDisplayTest.php
deleted file mode 100644
index 250f5e0..0000000
--- a/core/modules/entity/src/Tests/EntityDisplayTest.php
+++ /dev/null
@@ -1,366 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\entity\Tests\EntityDisplayTest.
- */
-
-namespace Drupal\entity\Tests;
-
-use Drupal\simpletest\DrupalUnitTestBase;
-
-/**
- * Tests the entity display configuration entities.
- */
-class EntityDisplayTest extends DrupalUnitTestBase {
-
-  public static $modules = array('entity', 'field', 'entity_test', 'user', 'text', 'entity_test');
-
-  public static function getInfo() {
-    return array(
-      'name' => 'Entity display configuration entities',
-      'description' => 'Tests the entity display configuration entities.',
-      'group' => 'Entity API',
-    );
-  }
-
-  protected function setUp() {
-    parent::setUp();
-    $this->installConfig(array('field'));
-  }
-
-  /**
-   * Tests basic CRUD operations on entity display objects.
-   */
-  public function testEntityDisplayCRUD() {
-    $display = entity_create('entity_view_display', array(
-      'targetEntityType' => 'entity_test',
-      'bundle' => 'entity_test',
-      'mode' => 'default',
-    ));
-
-    $expected = array();
-
-    // Check that providing no 'weight' results in the highest current weight
-    // being assigned. The 'name' field's formatter has weight -5, therefore
-    // these follow.
-    $expected['component_1'] = array('weight' => -4);
-    $expected['component_2'] = array('weight' => -3);
-    $display->setComponent('component_1');
-    $display->setComponent('component_2');
-    $this->assertEqual($display->getComponent('component_1'), $expected['component_1']);
-    $this->assertEqual($display->getComponent('component_2'), $expected['component_2']);
-
-    // Check that arbitrary options are correctly stored.
-    $expected['component_3'] = array('weight' => 10, 'foo' => 'bar');
-    $display->setComponent('component_3', $expected['component_3']);
-    $this->assertEqual($display->getComponent('component_3'), $expected['component_3']);
-
-    // Check that the display can be properly saved and read back.
-    $display->save();
-    $display = entity_load('entity_view_display', $display->id());
-    foreach (array('component_1', 'component_2', 'component_3') as $name) {
-      $this->assertEqual($display->getComponent($name), $expected[$name]);
-    }
-
-    // Check that getComponents() returns options for all components.
-    $expected['name'] = array(
-      'label' => 'hidden',
-      'type' => 'string',
-      'weight' => -5,
-      'settings' => array(),
-    );
-    $this->assertEqual($display->getComponents(), $expected);
-
-    // Check that a component can be removed.
-    $display->removeComponent('component_3');
-    $this->assertNULL($display->getComponent('component_3'));
-
-    // Check that the removal is correctly persisted.
-    $display->save();
-    $display = entity_load('entity_view_display', $display->id());
-    $this->assertNULL($display->getComponent('component_3'));
-
-    // Check that CreateCopy() creates a new component that can be correclty
-    // saved.
-    entity_create('view_mode', array('id' => $display->targetEntityType . '.other_view_mode', 'targetEntityType' => $display->targetEntityType))->save();
-    $new_display = $display->createCopy('other_view_mode');
-    $new_display->save();
-    $new_display = entity_load('entity_view_display', $new_display->id());
-    $dependencies = $new_display->calculateDependencies();
-    $this->assertEqual(array('entity' => array('entity.view_mode.entity_test.other_view_mode'), 'module' => array('entity_test')), $dependencies);
-    $this->assertEqual($new_display->targetEntityType, $display->targetEntityType);
-    $this->assertEqual($new_display->bundle, $display->bundle);
-    $this->assertEqual($new_display->mode, 'other_view_mode');
-    $this->assertEqual($new_display->getComponents(), $display->getComponents());
-  }
-
-  /**
-   * Tests entity_get_display().
-   */
-  public function testEntityGetDisplay() {
-    // Check that entity_get_display() returns a fresh object when no
-    // configuration entry exists.
-    $display = entity_get_display('entity_test', 'entity_test', 'default');
-    $this->assertTrue($display->isNew());
-
-    // Add some components and save the display.
-    $display->setComponent('component_1', array('weight' => 10))
-      ->save();
-
-    // Check that entity_get_display() returns the correct object.
-    $display = entity_get_display('entity_test', 'entity_test', 'default');
-    $this->assertFalse($display->isNew());
-    $this->assertEqual($display->id, 'entity_test.entity_test.default');
-    $this->assertEqual($display->getComponent('component_1'), array('weight' => 10));
-  }
-
-  /**
-   * Tests the behavior of a field component within an entity display object.
-   */
-  public function testExtraFieldComponent() {
-    entity_test_create_bundle('bundle_with_extra_fields');
-    $display = entity_create('entity_view_display', array(
-      'targetEntityType' => 'entity_test',
-      'bundle' => 'bundle_with_extra_fields',
-      'mode' => 'default',
-    ));
-
-    // Check that the default visibility taken into account for extra fields
-    // unknown in the display.
-    $this->assertEqual($display->getComponent('display_extra_field'), array('weight' => 5));
-    $this->assertNull($display->getComponent('display_extra_field_hidden'));
-
-    // Check that setting explicit options overrides the defaults.
-    $display->removeComponent('display_extra_field');
-    $display->setComponent('display_extra_field_hidden', array('weight' => 10));
-    $this->assertNull($display->getComponent('display_extra_field'));
-    $this->assertEqual($display->getComponent('display_extra_field_hidden'), array('weight' => 10));
-  }
-
-  /**
-   * Tests the behavior of a field component within an entity display object.
-   */
-  public function testFieldComponent() {
-    $this->enableModules(array('field_test'));
-
-    $field_name = 'test_field';
-    // Create a field and an instance.
-    $field = entity_create('field_config', array(
-      'name' => $field_name,
-      'entity_type' => 'entity_test',
-      'type' => 'test_field'
-    ));
-    $field->save();
-    $instance = entity_create('field_instance_config', array(
-      'field_name' => $field_name,
-      'entity_type' => 'entity_test',
-      'bundle' => 'entity_test',
-    ));
-    $instance->save();
-
-    $display = entity_create('entity_view_display', array(
-      'targetEntityType' => 'entity_test',
-      'bundle' => 'entity_test',
-      'mode' => 'default',
-    ));
-
-    // Check that providing no options results in default values being used.
-    $display->setComponent($field_name);
-    $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->type);
-    $default_formatter = $field_type_info['default_formatter'];
-    $formatter_settings =  \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings($default_formatter);
-    $expected = array(
-      'weight' => -4,
-      'label' => 'above',
-      'type' => $default_formatter,
-      'settings' => $formatter_settings,
-    );
-    $this->assertEqual($display->getComponent($field_name), $expected);
-
-    // Check that the getFormatter() method returns the correct formatter plugin.
-    $formatter = $display->getRenderer($field_name);
-    $this->assertEqual($formatter->getPluginId(), $default_formatter);
-    $this->assertEqual($formatter->getSettings(), $formatter_settings);
-
-    // Check that the formatter is statically persisted, by assigning an
-    // arbitrary property and reading it back.
-    $random_value = $this->randomString();
-    $formatter->randomValue = $random_value;
-    $formatter = $display->getRenderer($field_name);
-    $this->assertEqual($formatter->randomValue, $random_value);
-
-    // Check that changing the definition creates a new formatter.
-    $display->setComponent($field_name, array(
-      'type' => 'field_test_multiple',
-    ));
-    $formatter = $display->getRenderer($field_name);
-    $this->assertEqual($formatter->getPluginId(), 'field_test_multiple');
-    $this->assertFalse(isset($formatter->randomValue));
-
-    // Check that the display has dependencies on the field and the module that
-    // provides the formatter.
-    $dependencies = $display->calculateDependencies();
-    $this->assertEqual(array('entity' => array('field.instance.entity_test.entity_test.test_field'), 'module' => array('entity_test', 'field_test')), $dependencies);
-  }
-
-  /**
-   * Tests the behavior of a field component for a base field.
-   */
-  public function testBaseFieldComponent() {
-    $display = entity_create('entity_view_display', array(
-      'targetEntityType' => 'entity_test_base_field_display',
-      'bundle' => 'entity_test_base_field_display',
-      'mode' => 'default',
-    ));
-
-    // Check that default options are correctly filled in.
-    $formatter_settings =  \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings('text_default');
-    $expected = array(
-      'test_no_display' => NULL,
-      'test_display_configurable' => array(
-        'label' => 'above',
-        'type' => 'text_default',
-        'settings' => $formatter_settings,
-        'weight' => 10,
-      ),
-      'test_display_non_configurable' => array(
-        'label' => 'above',
-        'type' => 'text_default',
-        'settings' => $formatter_settings,
-        'weight' => 11,
-      ),
-    );
-    foreach ($expected as $field_name => $options) {
-      $this->assertEqual($display->getComponent($field_name), $options);
-    }
-
-    // Check that saving the display only writes data for fields whose display
-    // is configurable.
-    $display->save();
-    $config = \Drupal::config('entity.view_display.' . $display->id());
-    $data = $config->get();
-    $this->assertFalse(isset($data['content']['test_no_display']));
-    $this->assertFalse(isset($data['hidden']['test_no_display']));
-    $this->assertEqual($data['content']['test_display_configurable'], $expected['test_display_configurable']);
-    $this->assertFalse(isset($data['content']['test_display_non_configurable']));
-    $this->assertFalse(isset($data['hidden']['test_display_non_configurable']));
-
-    // Check that defaults are correctly filled when loading the display.
-    $display = entity_load('entity_view_display', $display->id());
-    foreach ($expected as $field_name => $options) {
-      $this->assertEqual($display->getComponent($field_name), $options);
-    }
-
-    // Check that data manually written for fields whose display is not
-    // configurable is discarded when loading the display.
-    $data['content']['test_display_non_configurable'] = $expected['test_display_non_configurable'];
-    $data['content']['test_display_non_configurable']['weight']++;
-    $config->setData($data)->save();
-    $display = entity_load('entity_view_display', $display->id());
-    foreach ($expected as $field_name => $options) {
-      $this->assertEqual($display->getComponent($field_name), $options);
-    }
-  }
-
-  /**
-   * Tests renaming and deleting a bundle.
-   */
-  public function testRenameDeleteBundle() {
-    $this->enableModules(array('field_test', 'node', 'system', 'text'));
-    $this->installEntitySchema('node');
-
-    // Create a node bundle, display and form display object.
-    entity_create('node_type', array('type' => 'article'))->save();
-    entity_get_display('node', 'article', 'default')->save();
-    entity_get_form_display('node', 'article', 'default')->save();
-
-    // Rename the article bundle and assert the entity display is renamed.
-    $type = node_type_load('article');
-    $type->old_type = 'article';
-    $type->type = 'article_rename';
-    $type->save();
-    $old_display = entity_load('entity_view_display', 'node.article.default');
-    $this->assertFalse($old_display);
-    $old_form_display = entity_load('entity_form_display', 'node.article.default');
-    $this->assertFalse($old_form_display);
-    $new_display = entity_load('entity_view_display', 'node.article_rename.default');
-    $this->assertEqual('article_rename', $new_display->bundle);
-    $this->assertEqual('node.article_rename.default', $new_display->id);
-    $new_form_display = entity_load('entity_form_display', 'node.article_rename.default');
-    $this->assertEqual('article_rename', $new_form_display->bundle);
-    $this->assertEqual('node.article_rename.default', $new_form_display->id);
-
-    $expected_dependencies = array(
-      'entity' => array('field.instance.node.article_rename.body', 'node.type.article_rename'),
-      'module' => array('text')
-    );
-    // Check that the display has dependencies on the bundle, fields and the
-    // modules that provide the formatters.
-    $dependencies = $new_display->calculateDependencies();
-    $this->assertEqual($expected_dependencies, $dependencies);
-
-    // Check that the form display has dependencies on the bundle, fields and
-    // the modules that provide the formatters.
-    $dependencies = $new_form_display->calculateDependencies();
-    $this->assertEqual($expected_dependencies, $dependencies);
-
-    // Delete the bundle.
-    $type->delete();
-    $display = entity_load('entity_view_display', 'node.article_rename.default');
-    $this->assertFalse($display);
-    $form_display = entity_load('entity_form_display', 'node.article_rename.default');
-    $this->assertFalse($form_display);
-  }
-
-  /**
-   * Tests deleting field instance.
-   */
-  public function testDeleteFieldInstance() {
-    $this->enableModules(array('field_test'));
-
-    $field_name = 'test_field';
-    // Create a field and an instance.
-    $field = entity_create('field_config', array(
-      'name' => $field_name,
-      'entity_type' => 'entity_test',
-      'type' => 'test_field'
-    ));
-    $field->save();
-    $instance = entity_create('field_instance_config', array(
-      'field_name' => $field_name,
-      'entity_type' => 'entity_test',
-      'bundle' => 'entity_test',
-    ));
-    $instance->save();
-
-    // Create default and teaser entity display.
-    entity_create('view_mode', array('id' =>  'entity_test.teaser', 'targetEntityType' => 'entity_test'))->save();
-    entity_create('entity_view_display', array(
-      'targetEntityType' => 'entity_test',
-      'bundle' => 'entity_test',
-      'mode' => 'default',
-    ))->setComponent($field_name)->save();
-    entity_create('entity_view_display', array(
-      'targetEntityType' => 'entity_test',
-      'bundle' => 'entity_test',
-      'mode' => 'teaser',
-    ))->setComponent($field_name)->save();
-
-    // Check the component exists.
-    $display = entity_get_display('entity_test', 'entity_test', 'default');
-    $this->assertTrue($display->getComponent($field_name));
-    $display = entity_get_display('entity_test', 'entity_test', 'teaser');
-    $this->assertTrue($display->getComponent($field_name));
-
-    // Delete the instance.
-    $instance->delete();
-
-    // Check that the component has been removed from the entity displays.
-    $display = entity_get_display('entity_test', 'entity_test', 'default');
-    $this->assertFalse($display->getComponent($field_name));
-    $display = entity_get_display('entity_test', 'entity_test', 'teaser');
-    $this->assertFalse($display->getComponent($field_name));
-  }
-
-}
diff --git a/core/modules/entity/src/Tests/EntityFormDisplayTest.php b/core/modules/entity/src/Tests/EntityFormDisplayTest.php
deleted file mode 100644
index eb0477f..0000000
--- a/core/modules/entity/src/Tests/EntityFormDisplayTest.php
+++ /dev/null
@@ -1,230 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\entity\Tests\EntityFormDisplayTest.
- */
-
-namespace Drupal\entity\Tests;
-
-use Drupal\simpletest\DrupalUnitTestBase;
-
-/**
- * Tests the entity display configuration entities.
- */
-class EntityFormDisplayTest extends DrupalUnitTestBase {
-
-  public static $modules = array('entity', 'field', 'entity_test', 'user', 'text');
-
-  public static function getInfo() {
-    return array(
-      'name' => 'Entity form display configuration entities',
-      'description' => 'Tests the entity form display configuration entities.',
-      'group' => 'Entity API',
-    );
-  }
-
-  protected function setUp() {
-    parent::setUp();
-    $this->installConfig(array('field'));
-  }
-
-  /**
-   * Tests entity_get_form_display().
-   */
-  public function testEntityGetFromDisplay() {
-    // Check that entity_get_form_display() returns a fresh object when no
-    // configuration entry exists.
-    $form_display = entity_get_form_display('entity_test', 'entity_test', 'default');
-    $this->assertTrue($form_display->isNew());
-
-    // Add some components and save the display.
-    $form_display->setComponent('component_1', array('weight' => 10))
-      ->save();
-
-    // Check that entity_get_form_display() returns the correct object.
-    $form_display = entity_get_form_display('entity_test', 'entity_test', 'default');
-    $this->assertFalse($form_display->isNew());
-    $this->assertEqual($form_display->id, 'entity_test.entity_test.default');
-    $this->assertEqual($form_display->getComponent('component_1'), array('weight' => 10));
-  }
-
-  /**
-   * Tests the behavior of a field component within an EntityFormDisplay object.
-   */
-  public function testFieldComponent() {
-    $this->enableModules(array('field_test'));
-
-    // Create a field and an instance.
-    $field_name = 'test_field';
-    $field = entity_create('field_config', array(
-      'name' => $field_name,
-      'entity_type' => 'entity_test',
-      'type' => 'test_field'
-    ));
-    $field->save();
-    $instance = entity_create('field_instance_config', array(
-      'field_name' => $field_name,
-      'entity_type' => 'entity_test',
-      'bundle' => 'entity_test',
-    ));
-    $instance->save();
-
-    $form_display = entity_create('entity_form_display', array(
-      'targetEntityType' => 'entity_test',
-      'bundle' => 'entity_test',
-      'mode' => 'default',
-    ));
-
-    // Check that providing no options results in default values being used.
-    $form_display->setComponent($field_name);
-    $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->type);
-    $default_widget = $field_type_info['default_widget'];
-    $widget_settings = \Drupal::service('plugin.manager.field.widget')->getDefaultSettings($default_widget);
-    $expected = array(
-      'weight' => 0,
-      'type' => $default_widget,
-      'settings' => $widget_settings,
-    );
-    $this->assertEqual($form_display->getComponent($field_name), $expected);
-
-    // Check that the getWidget() method returns the correct widget plugin.
-    $widget = $form_display->getRenderer($field_name);
-    $this->assertEqual($widget->getPluginId(), $default_widget);
-    $this->assertEqual($widget->getSettings(), $widget_settings);
-
-    // Check that the widget is statically persisted, by assigning an
-    // arbitrary property and reading it back.
-    $random_value = $this->randomString();
-    $widget->randomValue = $random_value;
-    $widget = $form_display->getRenderer($field_name);
-    $this->assertEqual($widget->randomValue, $random_value);
-
-    // Check that changing the definition creates a new widget.
-    $form_display->setComponent($field_name, array(
-      'type' => 'field_test_multiple',
-    ));
-    $widget = $form_display->getRenderer($field_name);
-    $this->assertEqual($widget->getPluginId(), 'test_field_widget');
-    $this->assertFalse(isset($widget->randomValue));
-
-    // Check that specifying an unknown widget (e.g. case of a disabled module)
-    // gets stored as is in the display, but results in the default widget being
-    // used.
-    $form_display->setComponent($field_name, array(
-      'type' => 'unknown_widget',
-    ));
-    $options = $form_display->getComponent($field_name);
-    $this->assertEqual($options['type'], 'unknown_widget');
-    $widget = $form_display->getRenderer($field_name);
-    $this->assertEqual($widget->getPluginId(), $default_widget);
-  }
-
-  /**
-   * Tests the behavior of a field component for a base field.
-   */
-  public function testBaseFieldComponent() {
-    $display = entity_create('entity_form_display', array(
-      'targetEntityType' => 'entity_test_base_field_display',
-      'bundle' => 'entity_test_base_field_display',
-      'mode' => 'default',
-    ));
-
-    // Check that default options are correctly filled in.
-    $formatter_settings =  \Drupal::service('plugin.manager.field.widget')->getDefaultSettings('text_textfield');
-    $expected = array(
-      'test_no_display' => NULL,
-      'test_display_configurable' => array(
-        'type' => 'text_textfield',
-        'settings' => $formatter_settings,
-        'weight' => 10,
-      ),
-      'test_display_non_configurable' => array(
-        'type' => 'text_textfield',
-        'settings' => $formatter_settings,
-        'weight' => 11,
-      ),
-    );
-    foreach ($expected as $field_name => $options) {
-      $this->assertEqual($display->getComponent($field_name), $options);
-    }
-
-    // Check that saving the display only writes data for fields whose display
-    // is configurable.
-    $display->save();
-    $config = \Drupal::config('entity.form_display.' . $display->id());
-    $data = $config->get();
-    $this->assertFalse(isset($data['content']['test_no_display']));
-    $this->assertFalse(isset($data['hidden']['test_no_display']));
-    $this->assertEqual($data['content']['test_display_configurable'], $expected['test_display_configurable']);
-    $this->assertFalse(isset($data['content']['test_display_non_configurable']));
-    $this->assertFalse(isset($data['hidden']['test_display_non_configurable']));
-
-    // Check that defaults are correctly filled when loading the display.
-    $display = entity_load('entity_form_display', $display->id());
-    foreach ($expected as $field_name => $options) {
-      $this->assertEqual($display->getComponent($field_name), $options);
-    }
-
-    // Check that data manually written for fields whose display is not
-    // configurable is discarded when loading the display.
-    $data['content']['test_display_non_configurable'] = $expected['test_display_non_configurable'];
-    $data['content']['test_display_non_configurable']['weight']++;
-    $config->setData($data)->save();
-    $display = entity_load('entity_form_display', $display->id());
-    foreach ($expected as $field_name => $options) {
-      $this->assertEqual($display->getComponent($field_name), $options);
-    }
-  }
-
-  /**
-   * Tests deleting field instance.
-   */
-  public function testDeleteFieldInstance() {
-    $this->enableModules(array('field_sql_storage', 'field_test'));
-
-    $field_name = 'test_field';
-    // Create a field and an instance.
-    $field = entity_create('field_config', array(
-      'name' => $field_name,
-      'entity_type' => 'entity_test',
-      'type' => 'test_field'
-    ));
-    $field->save();
-    $instance = entity_create('field_instance_config', array(
-      'field_name' => $field_name,
-      'entity_type' => 'entity_test',
-      'bundle' => 'entity_test',
-    ));
-    $instance->save();
-
-    // Create default and compact entity display.
-    entity_create('form_mode', array('id' =>  'entity_test.compact', 'targetEntityType' => 'entity_test'))->save();
-    entity_create('entity_form_display', array(
-      'targetEntityType' => 'entity_test',
-      'bundle' => 'entity_test',
-      'mode' => 'default',
-    ))->setComponent($field_name)->save();
-    entity_create('entity_form_display', array(
-      'targetEntityType' => 'entity_test',
-      'bundle' => 'entity_test',
-      'mode' => 'compact',
-    ))->setComponent($field_name)->save();
-
-    // Check the component exists.
-    $display = entity_get_form_display('entity_test', 'entity_test', 'default');
-    $this->assertTrue($display->getComponent($field_name));
-    $display = entity_get_form_display('entity_test', 'entity_test', 'compact');
-    $this->assertTrue($display->getComponent($field_name));
-
-    // Delete the instance.
-    $instance->delete();
-
-    // Check that the component has been removed from the entity displays.
-    $display = entity_get_form_display('entity_test', 'entity_test', 'default');
-    $this->assertFalse($display->getComponent($field_name));
-    $display = entity_get_form_display('entity_test', 'entity_test', 'compact');
-    $this->assertFalse($display->getComponent($field_name));
-  }
-
-}
diff --git a/core/modules/field_ui/src/Tests/EntityDisplayModeTest.php b/core/modules/field_ui/src/Tests/EntityDisplayModeTest.php
new file mode 100644
index 0000000..3462595
--- /dev/null
+++ b/core/modules/field_ui/src/Tests/EntityDisplayModeTest.php
@@ -0,0 +1,124 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\field_ui\Tests\EntityDisplayModeTest.
+ */
+
+namespace Drupal\field_ui\Tests;
+
+use Drupal\simpletest\WebTestBase;
+
+/**
+ * Tests the entity display mode configuration entities.
+ */
+class EntityDisplayModeTest extends WebTestBase {
+
+  /**
+   * Modules to enable.
+   *
+   * @var array
+   */
+  public static $modules = array('entity_test');
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Entity display modes UI',
+      'description' => 'Tests the entity display modes UI.',
+      'group' => 'Field UI',
+    );
+  }
+
+  /**
+   * Tests the EntityViewMode user interface.
+   */
+  public function testEntityViewModeUI() {
+    // Test the listing page.
+    $this->drupalGet('admin/structure/display-modes/view');
+    $this->assertResponse(403);
+    $this->drupalLogin($this->drupalCreateUser(array('administer display modes')));
+    $this->drupalGet('admin/structure/display-modes/view');
+    $this->assertResponse(200);
+    $this->assertText(t('Add new view mode'));
+    $this->assertLinkByHref('admin/structure/display-modes/view/add');
+
+    $this->drupalGet('admin/structure/display-modes/view/add/entity_test_mulrev');
+    $this->assertResponse(404);
+
+    $this->drupalGet('admin/structure/display-modes/view/add');
+    $this->assertNoLink(t('Test entity - revisions and data table'), 'An entity type with no view builder cannot have view modes.');
+
+    // Test adding a view mode including dots in machine_name.
+    $this->clickLink(t('Test entity'));
+    $edit = array(
+      'id' => strtolower($this->randomName()) . '.' . strtolower($this->randomName()),
+      'label' => $this->randomString(),
+    );
+    $this->drupalPostForm(NULL, $edit, t('Save'));
+    $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
+
+    // Test adding a view mode.
+    $edit = array(
+      'id' => strtolower($this->randomName()),
+      'label' => $this->randomString(),
+    );
+    $this->drupalPostForm(NULL, $edit, t('Save'));
+    $this->assertRaw(t('Saved the %label view mode.', array('%label' => $edit['label'])));
+
+    // Test editing the view mode.
+    $this->drupalGet('admin/structure/display-modes/view/manage/entity_test.' . $edit['id']);
+
+    // Test deleting the view mode.
+    $this->clickLink(t('Delete'));
+    $this->assertRaw(t('Are you sure you want to delete the %label view mode?', array('%label' => $edit['label'])));
+    $this->drupalPostForm(NULL, NULL, t('Delete'));
+    $this->assertRaw(t('Deleted the %label view mode.', array('%label' => $edit['label'])));
+  }
+
+  /**
+   * Tests the EntityFormMode user interface.
+   */
+  public function testEntityFormModeUI() {
+    // Test the listing page.
+    $this->drupalGet('admin/structure/display-modes/form');
+    $this->assertResponse(403);
+    $this->drupalLogin($this->drupalCreateUser(array('administer display modes')));
+    $this->drupalGet('admin/structure/display-modes/form');
+    $this->assertResponse(200);
+    $this->assertText(t('Add new form mode'));
+    $this->assertLinkByHref('admin/structure/display-modes/form/add');
+
+    $this->drupalGet('admin/structure/display-modes/form/add/entity_test_no_label');
+    $this->assertResponse(404);
+
+    $this->drupalGet('admin/structure/display-modes/form/add');
+    $this->assertNoLink(t('Entity Test without label'), 'An entity type with no form cannot have form modes.');
+
+    // Test adding a view mode including dots in machine_name.
+    $this->clickLink(t('Test entity'));
+    $edit = array(
+      'id' => strtolower($this->randomName()) . '.' . strtolower($this->randomName()),
+      'label' => $this->randomString(),
+    );
+    $this->drupalPostForm(NULL, $edit, t('Save'));
+    $this->assertRaw('The machine-readable name must contain only lowercase letters, numbers, and underscores.');
+
+    // Test adding a form mode.
+    $edit = array(
+      'id' => strtolower($this->randomName()),
+      'label' => $this->randomString(),
+    );
+    $this->drupalPostForm(NULL, $edit, t('Save'));
+    $this->assertRaw(t('Saved the %label form mode.', array('%label' => $edit['label'])));
+
+    // Test editing the form mode.
+    $this->drupalGet('admin/structure/display-modes/form/manage/entity_test.' . $edit['id']);
+
+    // Test deleting the form mode.
+    $this->clickLink(t('Delete'));
+    $this->assertRaw(t('Are you sure you want to delete the %label form mode?', array('%label' => $edit['label'])));
+    $this->drupalPostForm(NULL, NULL, t('Delete'));
+    $this->assertRaw(t('Deleted the %label form mode.', array('%label' => $edit['label'])));
+  }
+
+}
diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php
new file mode 100644
index 0000000..0fa9d54
--- /dev/null
+++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php
@@ -0,0 +1,366 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\field_ui\Tests\EntityDisplayTest.
+ */
+
+namespace Drupal\field_ui\Tests;
+
+use Drupal\simpletest\DrupalUnitTestBase;
+
+/**
+ * Tests the entity display configuration entities.
+ */
+class EntityDisplayTest extends DrupalUnitTestBase {
+
+  public static $modules = array('entity', 'field', 'entity_test', 'user', 'text', 'entity_test');
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Entity display configuration entities',
+      'description' => 'Tests the entity display configuration entities.',
+      'group' => 'Field UI',
+    );
+  }
+
+  protected function setUp() {
+    parent::setUp();
+    $this->installConfig(array('field'));
+  }
+
+  /**
+   * Tests basic CRUD operations on entity display objects.
+   */
+  public function testEntityDisplayCRUD() {
+    $display = entity_create('entity_view_display', array(
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'default',
+    ));
+
+    $expected = array();
+
+    // Check that providing no 'weight' results in the highest current weight
+    // being assigned. The 'name' field's formatter has weight -5, therefore
+    // these follow.
+    $expected['component_1'] = array('weight' => -4);
+    $expected['component_2'] = array('weight' => -3);
+    $display->setComponent('component_1');
+    $display->setComponent('component_2');
+    $this->assertEqual($display->getComponent('component_1'), $expected['component_1']);
+    $this->assertEqual($display->getComponent('component_2'), $expected['component_2']);
+
+    // Check that arbitrary options are correctly stored.
+    $expected['component_3'] = array('weight' => 10, 'foo' => 'bar');
+    $display->setComponent('component_3', $expected['component_3']);
+    $this->assertEqual($display->getComponent('component_3'), $expected['component_3']);
+
+    // Check that the display can be properly saved and read back.
+    $display->save();
+    $display = entity_load('entity_view_display', $display->id());
+    foreach (array('component_1', 'component_2', 'component_3') as $name) {
+      $this->assertEqual($display->getComponent($name), $expected[$name]);
+    }
+
+    // Check that getComponents() returns options for all components.
+    $expected['name'] = array(
+      'label' => 'hidden',
+      'type' => 'string',
+      'weight' => -5,
+      'settings' => array(),
+    );
+    $this->assertEqual($display->getComponents(), $expected);
+
+    // Check that a component can be removed.
+    $display->removeComponent('component_3');
+    $this->assertNULL($display->getComponent('component_3'));
+
+    // Check that the removal is correctly persisted.
+    $display->save();
+    $display = entity_load('entity_view_display', $display->id());
+    $this->assertNULL($display->getComponent('component_3'));
+
+    // Check that CreateCopy() creates a new component that can be correclty
+    // saved.
+    entity_create('view_mode', array('id' => $display->targetEntityType . '.other_view_mode', 'targetEntityType' => $display->targetEntityType))->save();
+    $new_display = $display->createCopy('other_view_mode');
+    $new_display->save();
+    $new_display = entity_load('entity_view_display', $new_display->id());
+    $dependencies = $new_display->calculateDependencies();
+    $this->assertEqual(array('entity' => array('entity.view_mode.entity_test.other_view_mode'), 'module' => array('entity_test')), $dependencies);
+    $this->assertEqual($new_display->targetEntityType, $display->targetEntityType);
+    $this->assertEqual($new_display->bundle, $display->bundle);
+    $this->assertEqual($new_display->mode, 'other_view_mode');
+    $this->assertEqual($new_display->getComponents(), $display->getComponents());
+  }
+
+  /**
+   * Tests entity_get_display().
+   */
+  public function testEntityGetDisplay() {
+    // Check that entity_get_display() returns a fresh object when no
+    // configuration entry exists.
+    $display = entity_get_display('entity_test', 'entity_test', 'default');
+    $this->assertTrue($display->isNew());
+
+    // Add some components and save the display.
+    $display->setComponent('component_1', array('weight' => 10))
+      ->save();
+
+    // Check that entity_get_display() returns the correct object.
+    $display = entity_get_display('entity_test', 'entity_test', 'default');
+    $this->assertFalse($display->isNew());
+    $this->assertEqual($display->id, 'entity_test.entity_test.default');
+    $this->assertEqual($display->getComponent('component_1'), array('weight' => 10));
+  }
+
+  /**
+   * Tests the behavior of a field component within an entity display object.
+   */
+  public function testExtraFieldComponent() {
+    entity_test_create_bundle('bundle_with_extra_fields');
+    $display = entity_create('entity_view_display', array(
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'bundle_with_extra_fields',
+      'mode' => 'default',
+    ));
+
+    // Check that the default visibility taken into account for extra fields
+    // unknown in the display.
+    $this->assertEqual($display->getComponent('display_extra_field'), array('weight' => 5));
+    $this->assertNull($display->getComponent('display_extra_field_hidden'));
+
+    // Check that setting explicit options overrides the defaults.
+    $display->removeComponent('display_extra_field');
+    $display->setComponent('display_extra_field_hidden', array('weight' => 10));
+    $this->assertNull($display->getComponent('display_extra_field'));
+    $this->assertEqual($display->getComponent('display_extra_field_hidden'), array('weight' => 10));
+  }
+
+  /**
+   * Tests the behavior of a field component within an entity display object.
+   */
+  public function testFieldComponent() {
+    $this->enableModules(array('field_test'));
+
+    $field_name = 'test_field';
+    // Create a field and an instance.
+    $field = entity_create('field_config', array(
+      'name' => $field_name,
+      'entity_type' => 'entity_test',
+      'type' => 'test_field'
+    ));
+    $field->save();
+    $instance = entity_create('field_instance_config', array(
+      'field_name' => $field_name,
+      'entity_type' => 'entity_test',
+      'bundle' => 'entity_test',
+    ));
+    $instance->save();
+
+    $display = entity_create('entity_view_display', array(
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'default',
+    ));
+
+    // Check that providing no options results in default values being used.
+    $display->setComponent($field_name);
+    $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->type);
+    $default_formatter = $field_type_info['default_formatter'];
+    $formatter_settings =  \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings($default_formatter);
+    $expected = array(
+      'weight' => -4,
+      'label' => 'above',
+      'type' => $default_formatter,
+      'settings' => $formatter_settings,
+    );
+    $this->assertEqual($display->getComponent($field_name), $expected);
+
+    // Check that the getFormatter() method returns the correct formatter plugin.
+    $formatter = $display->getRenderer($field_name);
+    $this->assertEqual($formatter->getPluginId(), $default_formatter);
+    $this->assertEqual($formatter->getSettings(), $formatter_settings);
+
+    // Check that the formatter is statically persisted, by assigning an
+    // arbitrary property and reading it back.
+    $random_value = $this->randomString();
+    $formatter->randomValue = $random_value;
+    $formatter = $display->getRenderer($field_name);
+    $this->assertEqual($formatter->randomValue, $random_value);
+
+    // Check that changing the definition creates a new formatter.
+    $display->setComponent($field_name, array(
+      'type' => 'field_test_multiple',
+    ));
+    $formatter = $display->getRenderer($field_name);
+    $this->assertEqual($formatter->getPluginId(), 'field_test_multiple');
+    $this->assertFalse(isset($formatter->randomValue));
+
+    // Check that the display has dependencies on the field and the module that
+    // provides the formatter.
+    $dependencies = $display->calculateDependencies();
+    $this->assertEqual(array('entity' => array('field.instance.entity_test.entity_test.test_field'), 'module' => array('entity_test', 'field_test')), $dependencies);
+  }
+
+  /**
+   * Tests the behavior of a field component for a base field.
+   */
+  public function testBaseFieldComponent() {
+    $display = entity_create('entity_view_display', array(
+      'targetEntityType' => 'entity_test_base_field_display',
+      'bundle' => 'entity_test_base_field_display',
+      'mode' => 'default',
+    ));
+
+    // Check that default options are correctly filled in.
+    $formatter_settings =  \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings('text_default');
+    $expected = array(
+      'test_no_display' => NULL,
+      'test_display_configurable' => array(
+        'label' => 'above',
+        'type' => 'text_default',
+        'settings' => $formatter_settings,
+        'weight' => 10,
+      ),
+      'test_display_non_configurable' => array(
+        'label' => 'above',
+        'type' => 'text_default',
+        'settings' => $formatter_settings,
+        'weight' => 11,
+      ),
+    );
+    foreach ($expected as $field_name => $options) {
+      $this->assertEqual($display->getComponent($field_name), $options);
+    }
+
+    // Check that saving the display only writes data for fields whose display
+    // is configurable.
+    $display->save();
+    $config = \Drupal::config('entity.view_display.' . $display->id());
+    $data = $config->get();
+    $this->assertFalse(isset($data['content']['test_no_display']));
+    $this->assertFalse(isset($data['hidden']['test_no_display']));
+    $this->assertEqual($data['content']['test_display_configurable'], $expected['test_display_configurable']);
+    $this->assertFalse(isset($data['content']['test_display_non_configurable']));
+    $this->assertFalse(isset($data['hidden']['test_display_non_configurable']));
+
+    // Check that defaults are correctly filled when loading the display.
+    $display = entity_load('entity_view_display', $display->id());
+    foreach ($expected as $field_name => $options) {
+      $this->assertEqual($display->getComponent($field_name), $options);
+    }
+
+    // Check that data manually written for fields whose display is not
+    // configurable is discarded when loading the display.
+    $data['content']['test_display_non_configurable'] = $expected['test_display_non_configurable'];
+    $data['content']['test_display_non_configurable']['weight']++;
+    $config->setData($data)->save();
+    $display = entity_load('entity_view_display', $display->id());
+    foreach ($expected as $field_name => $options) {
+      $this->assertEqual($display->getComponent($field_name), $options);
+    }
+  }
+
+  /**
+   * Tests renaming and deleting a bundle.
+   */
+  public function testRenameDeleteBundle() {
+    $this->enableModules(array('field_test', 'node', 'system', 'text'));
+    $this->installEntitySchema('node');
+
+    // Create a node bundle, display and form display object.
+    entity_create('node_type', array('type' => 'article'))->save();
+    entity_get_display('node', 'article', 'default')->save();
+    entity_get_form_display('node', 'article', 'default')->save();
+
+    // Rename the article bundle and assert the entity display is renamed.
+    $type = node_type_load('article');
+    $type->old_type = 'article';
+    $type->type = 'article_rename';
+    $type->save();
+    $old_display = entity_load('entity_view_display', 'node.article.default');
+    $this->assertFalse($old_display);
+    $old_form_display = entity_load('entity_form_display', 'node.article.default');
+    $this->assertFalse($old_form_display);
+    $new_display = entity_load('entity_view_display', 'node.article_rename.default');
+    $this->assertEqual('article_rename', $new_display->bundle);
+    $this->assertEqual('node.article_rename.default', $new_display->id);
+    $new_form_display = entity_load('entity_form_display', 'node.article_rename.default');
+    $this->assertEqual('article_rename', $new_form_display->bundle);
+    $this->assertEqual('node.article_rename.default', $new_form_display->id);
+
+    $expected_dependencies = array(
+      'entity' => array('field.instance.node.article_rename.body', 'node.type.article_rename'),
+      'module' => array('text')
+    );
+    // Check that the display has dependencies on the bundle, fields and the
+    // modules that provide the formatters.
+    $dependencies = $new_display->calculateDependencies();
+    $this->assertEqual($expected_dependencies, $dependencies);
+
+    // Check that the form display has dependencies on the bundle, fields and
+    // the modules that provide the formatters.
+    $dependencies = $new_form_display->calculateDependencies();
+    $this->assertEqual($expected_dependencies, $dependencies);
+
+    // Delete the bundle.
+    $type->delete();
+    $display = entity_load('entity_view_display', 'node.article_rename.default');
+    $this->assertFalse($display);
+    $form_display = entity_load('entity_form_display', 'node.article_rename.default');
+    $this->assertFalse($form_display);
+  }
+
+  /**
+   * Tests deleting field instance.
+   */
+  public function testDeleteFieldInstance() {
+    $this->enableModules(array('field_test'));
+
+    $field_name = 'test_field';
+    // Create a field and an instance.
+    $field = entity_create('field_config', array(
+      'name' => $field_name,
+      'entity_type' => 'entity_test',
+      'type' => 'test_field'
+    ));
+    $field->save();
+    $instance = entity_create('field_instance_config', array(
+      'field_name' => $field_name,
+      'entity_type' => 'entity_test',
+      'bundle' => 'entity_test',
+    ));
+    $instance->save();
+
+    // Create default and teaser entity display.
+    entity_create('view_mode', array('id' =>  'entity_test.teaser', 'targetEntityType' => 'entity_test'))->save();
+    entity_create('entity_view_display', array(
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'default',
+    ))->setComponent($field_name)->save();
+    entity_create('entity_view_display', array(
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'teaser',
+    ))->setComponent($field_name)->save();
+
+    // Check the component exists.
+    $display = entity_get_display('entity_test', 'entity_test', 'default');
+    $this->assertTrue($display->getComponent($field_name));
+    $display = entity_get_display('entity_test', 'entity_test', 'teaser');
+    $this->assertTrue($display->getComponent($field_name));
+
+    // Delete the instance.
+    $instance->delete();
+
+    // Check that the component has been removed from the entity displays.
+    $display = entity_get_display('entity_test', 'entity_test', 'default');
+    $this->assertFalse($display->getComponent($field_name));
+    $display = entity_get_display('entity_test', 'entity_test', 'teaser');
+    $this->assertFalse($display->getComponent($field_name));
+  }
+
+}
diff --git a/core/modules/field_ui/src/Tests/EntityFormDisplayTest.php b/core/modules/field_ui/src/Tests/EntityFormDisplayTest.php
new file mode 100644
index 0000000..a5fb04c
--- /dev/null
+++ b/core/modules/field_ui/src/Tests/EntityFormDisplayTest.php
@@ -0,0 +1,230 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\field_ui\Tests\EntityFormDisplayTest.
+ */
+
+namespace Drupal\field_ui\Tests;
+
+use Drupal\simpletest\DrupalUnitTestBase;
+
+/**
+ * Tests the entity display configuration entities.
+ */
+class EntityFormDisplayTest extends DrupalUnitTestBase {
+
+  public static $modules = array('entity', 'field', 'entity_test', 'user', 'text');
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Entity form display configuration entities',
+      'description' => 'Tests the entity form display configuration entities.',
+      'group' => 'Field UI',
+    );
+  }
+
+  protected function setUp() {
+    parent::setUp();
+    $this->installConfig(array('field'));
+  }
+
+  /**
+   * Tests entity_get_form_display().
+   */
+  public function testEntityGetFromDisplay() {
+    // Check that entity_get_form_display() returns a fresh object when no
+    // configuration entry exists.
+    $form_display = entity_get_form_display('entity_test', 'entity_test', 'default');
+    $this->assertTrue($form_display->isNew());
+
+    // Add some components and save the display.
+    $form_display->setComponent('component_1', array('weight' => 10))
+      ->save();
+
+    // Check that entity_get_form_display() returns the correct object.
+    $form_display = entity_get_form_display('entity_test', 'entity_test', 'default');
+    $this->assertFalse($form_display->isNew());
+    $this->assertEqual($form_display->id, 'entity_test.entity_test.default');
+    $this->assertEqual($form_display->getComponent('component_1'), array('weight' => 10));
+  }
+
+  /**
+   * Tests the behavior of a field component within an EntityFormDisplay object.
+   */
+  public function testFieldComponent() {
+    $this->enableModules(array('field_test'));
+
+    // Create a field and an instance.
+    $field_name = 'test_field';
+    $field = entity_create('field_config', array(
+      'name' => $field_name,
+      'entity_type' => 'entity_test',
+      'type' => 'test_field'
+    ));
+    $field->save();
+    $instance = entity_create('field_instance_config', array(
+      'field_name' => $field_name,
+      'entity_type' => 'entity_test',
+      'bundle' => 'entity_test',
+    ));
+    $instance->save();
+
+    $form_display = entity_create('entity_form_display', array(
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'default',
+    ));
+
+    // Check that providing no options results in default values being used.
+    $form_display->setComponent($field_name);
+    $field_type_info = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->type);
+    $default_widget = $field_type_info['default_widget'];
+    $widget_settings = \Drupal::service('plugin.manager.field.widget')->getDefaultSettings($default_widget);
+    $expected = array(
+      'weight' => 0,
+      'type' => $default_widget,
+      'settings' => $widget_settings,
+    );
+    $this->assertEqual($form_display->getComponent($field_name), $expected);
+
+    // Check that the getWidget() method returns the correct widget plugin.
+    $widget = $form_display->getRenderer($field_name);
+    $this->assertEqual($widget->getPluginId(), $default_widget);
+    $this->assertEqual($widget->getSettings(), $widget_settings);
+
+    // Check that the widget is statically persisted, by assigning an
+    // arbitrary property and reading it back.
+    $random_value = $this->randomString();
+    $widget->randomValue = $random_value;
+    $widget = $form_display->getRenderer($field_name);
+    $this->assertEqual($widget->randomValue, $random_value);
+
+    // Check that changing the definition creates a new widget.
+    $form_display->setComponent($field_name, array(
+      'type' => 'field_test_multiple',
+    ));
+    $widget = $form_display->getRenderer($field_name);
+    $this->assertEqual($widget->getPluginId(), 'test_field_widget');
+    $this->assertFalse(isset($widget->randomValue));
+
+    // Check that specifying an unknown widget (e.g. case of a disabled module)
+    // gets stored as is in the display, but results in the default widget being
+    // used.
+    $form_display->setComponent($field_name, array(
+      'type' => 'unknown_widget',
+    ));
+    $options = $form_display->getComponent($field_name);
+    $this->assertEqual($options['type'], 'unknown_widget');
+    $widget = $form_display->getRenderer($field_name);
+    $this->assertEqual($widget->getPluginId(), $default_widget);
+  }
+
+  /**
+   * Tests the behavior of a field component for a base field.
+   */
+  public function testBaseFieldComponent() {
+    $display = entity_create('entity_form_display', array(
+      'targetEntityType' => 'entity_test_base_field_display',
+      'bundle' => 'entity_test_base_field_display',
+      'mode' => 'default',
+    ));
+
+    // Check that default options are correctly filled in.
+    $formatter_settings =  \Drupal::service('plugin.manager.field.widget')->getDefaultSettings('text_textfield');
+    $expected = array(
+      'test_no_display' => NULL,
+      'test_display_configurable' => array(
+        'type' => 'text_textfield',
+        'settings' => $formatter_settings,
+        'weight' => 10,
+      ),
+      'test_display_non_configurable' => array(
+        'type' => 'text_textfield',
+        'settings' => $formatter_settings,
+        'weight' => 11,
+      ),
+    );
+    foreach ($expected as $field_name => $options) {
+      $this->assertEqual($display->getComponent($field_name), $options);
+    }
+
+    // Check that saving the display only writes data for fields whose display
+    // is configurable.
+    $display->save();
+    $config = \Drupal::config('entity.form_display.' . $display->id());
+    $data = $config->get();
+    $this->assertFalse(isset($data['content']['test_no_display']));
+    $this->assertFalse(isset($data['hidden']['test_no_display']));
+    $this->assertEqual($data['content']['test_display_configurable'], $expected['test_display_configurable']);
+    $this->assertFalse(isset($data['content']['test_display_non_configurable']));
+    $this->assertFalse(isset($data['hidden']['test_display_non_configurable']));
+
+    // Check that defaults are correctly filled when loading the display.
+    $display = entity_load('entity_form_display', $display->id());
+    foreach ($expected as $field_name => $options) {
+      $this->assertEqual($display->getComponent($field_name), $options);
+    }
+
+    // Check that data manually written for fields whose display is not
+    // configurable is discarded when loading the display.
+    $data['content']['test_display_non_configurable'] = $expected['test_display_non_configurable'];
+    $data['content']['test_display_non_configurable']['weight']++;
+    $config->setData($data)->save();
+    $display = entity_load('entity_form_display', $display->id());
+    foreach ($expected as $field_name => $options) {
+      $this->assertEqual($display->getComponent($field_name), $options);
+    }
+  }
+
+  /**
+   * Tests deleting field instance.
+   */
+  public function testDeleteFieldInstance() {
+    $this->enableModules(array('field_sql_storage', 'field_test'));
+
+    $field_name = 'test_field';
+    // Create a field and an instance.
+    $field = entity_create('field_config', array(
+      'name' => $field_name,
+      'entity_type' => 'entity_test',
+      'type' => 'test_field'
+    ));
+    $field->save();
+    $instance = entity_create('field_instance_config', array(
+      'field_name' => $field_name,
+      'entity_type' => 'entity_test',
+      'bundle' => 'entity_test',
+    ));
+    $instance->save();
+
+    // Create default and compact entity display.
+    entity_create('form_mode', array('id' =>  'entity_test.compact', 'targetEntityType' => 'entity_test'))->save();
+    entity_create('entity_form_display', array(
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'default',
+    ))->setComponent($field_name)->save();
+    entity_create('entity_form_display', array(
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'compact',
+    ))->setComponent($field_name)->save();
+
+    // Check the component exists.
+    $display = entity_get_form_display('entity_test', 'entity_test', 'default');
+    $this->assertTrue($display->getComponent($field_name));
+    $display = entity_get_form_display('entity_test', 'entity_test', 'compact');
+    $this->assertTrue($display->getComponent($field_name));
+
+    // Delete the instance.
+    $instance->delete();
+
+    // Check that the component has been removed from the entity displays.
+    $display = entity_get_form_display('entity_test', 'entity_test', 'default');
+    $this->assertFalse($display->getComponent($field_name));
+    $display = entity_get_form_display('entity_test', 'entity_test', 'compact');
+    $this->assertFalse($display->getComponent($field_name));
+  }
+
+}
