Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / src / Functional / Update / UpdateEntityDisplayTest.php
index 698d331099cb0668b060716bdf77118bc7a7d0a2..187c7ac9199b43b5449cec8699bd909d5c717ce9 100644 (file)
@@ -7,9 +7,10 @@ use Drupal\Core\Entity\Entity\EntityViewDisplay;
 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
 
 /**
- * Tests system_post_update_add_region_to_entity_displays().
+ * Tests updates for entity displays.
  *
  * @group Update
+ * @group legacy
  */
 class UpdateEntityDisplayTest extends UpdatePathTestBase {
 
@@ -24,8 +25,10 @@ class UpdateEntityDisplayTest extends UpdatePathTestBase {
 
   /**
    * Tests that entity displays are updated with regions for their fields.
+   *
+   * @see system_post_update_add_region_to_entity_displays()
    */
-  public function testUpdate() {
+  public function testRegionUpdate() {
     // No region key appears pre-update.
     $entity_form_display = EntityFormDisplay::load('node.article.default');
     $options = $entity_form_display->getComponent('body');
@@ -47,4 +50,22 @@ class UpdateEntityDisplayTest extends UpdatePathTestBase {
     $this->assertIdentical('content', $options['region']);
   }
 
+  /**
+   * Tests that entity displays are updated to properly store extra fields.
+   *
+   * @see system_post_update_extra_fields()
+   */
+  public function testExtraFieldsUpdate() {
+    $assertion = function ($expected_keys) {
+      $entity_view_display = EntityViewDisplay::load('node.article.default');
+      $this->assertEquals($expected_keys, array_keys($entity_view_display->getComponent('links')));
+    };
+
+    // Before the update extra fields are missing additional configuration.
+    $assertion(['weight', 'region']);
+    $this->runUpdates();
+    // After the update the additional configuration is present.
+    $assertion(['weight', 'region', 'settings', 'third_party_settings']);
+  }
+
 }