3 namespace Drupal\Tests\system\Functional\Update;
5 use Drupal\Core\Entity\Entity\EntityFormDisplay;
6 use Drupal\Core\Entity\Entity\EntityViewDisplay;
7 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
10 * Tests updates for entity displays.
15 class UpdateEntityDisplayTest extends UpdatePathTestBase {
20 protected function setDatabaseDumpFiles() {
21 $this->databaseDumpFiles = [
22 __DIR__ . '/../../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
27 * Tests that entity displays are updated with regions for their fields.
29 * @see system_post_update_add_region_to_entity_displays()
31 public function testRegionUpdate() {
32 // No region key appears pre-update.
33 $entity_form_display = EntityFormDisplay::load('node.article.default');
34 $options = $entity_form_display->getComponent('body');
35 $this->assertFalse(array_key_exists('region', $options));
37 $entity_view_display = EntityViewDisplay::load('node.article.default');
38 $options = $entity_view_display->getComponent('body');
39 $this->assertFalse(array_key_exists('region', $options));
43 // The region key has been populated with 'content'.
44 $entity_form_display = EntityFormDisplay::load('node.article.default');
45 $options = $entity_form_display->getComponent('body');
46 $this->assertIdentical('content', $options['region']);
48 $entity_view_display = EntityViewDisplay::load('node.article.default');
49 $options = $entity_view_display->getComponent('body');
50 $this->assertIdentical('content', $options['region']);
54 * Tests that entity displays are updated to properly store extra fields.
56 * @see system_post_update_extra_fields()
58 public function testExtraFieldsUpdate() {
59 $assertion = function ($expected_keys) {
60 $entity_view_display = EntityViewDisplay::load('node.article.default');
61 $this->assertEquals($expected_keys, array_keys($entity_view_display->getComponent('links')));
64 // Before the update extra fields are missing additional configuration.
65 $assertion(['weight', 'region']);
67 // After the update the additional configuration is present.
68 $assertion(['weight', 'region', 'settings', 'third_party_settings']);