698d331099cb0668b060716bdf77118bc7a7d0a2
[yaffs-website] / web / core / modules / system / tests / src / Functional / Update / UpdateEntityDisplayTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Update;
4
5 use Drupal\Core\Entity\Entity\EntityFormDisplay;
6 use Drupal\Core\Entity\Entity\EntityViewDisplay;
7 use Drupal\FunctionalTests\Update\UpdatePathTestBase;
8
9 /**
10  * Tests system_post_update_add_region_to_entity_displays().
11  *
12  * @group Update
13  */
14 class UpdateEntityDisplayTest extends UpdatePathTestBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   protected function setDatabaseDumpFiles() {
20     $this->databaseDumpFiles = [
21       __DIR__ . '/../../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
22     ];
23   }
24
25   /**
26    * Tests that entity displays are updated with regions for their fields.
27    */
28   public function testUpdate() {
29     // No region key appears pre-update.
30     $entity_form_display = EntityFormDisplay::load('node.article.default');
31     $options = $entity_form_display->getComponent('body');
32     $this->assertFalse(array_key_exists('region', $options));
33
34     $entity_view_display = EntityViewDisplay::load('node.article.default');
35     $options = $entity_view_display->getComponent('body');
36     $this->assertFalse(array_key_exists('region', $options));
37
38     $this->runUpdates();
39
40     // The region key has been populated with 'content'.
41     $entity_form_display = EntityFormDisplay::load('node.article.default');
42     $options = $entity_form_display->getComponent('body');
43     $this->assertIdentical('content', $options['region']);
44
45     $entity_view_display = EntityViewDisplay::load('node.article.default');
46     $options = $entity_view_display->getComponent('body');
47     $this->assertIdentical('content', $options['region']);
48   }
49
50 }