UpdateEntityDisplayTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Update/UpdateEntityDisplayTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Update;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
class UpdateEntityDisplayTest extends UpdatePathTestBase {
protected $defaultTheme = 'stark';
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
];
}
public function testRegionUpdate() {
$entity_form_display = EntityFormDisplay::load('node.article.default');
$options = $entity_form_display
->getComponent('body');
$this
->assertFalse(array_key_exists('region', $options));
$entity_view_display = EntityViewDisplay::load('node.article.default');
$options = $entity_view_display
->getComponent('body');
$this
->assertFalse(array_key_exists('region', $options));
$this
->runUpdates();
$entity_form_display = EntityFormDisplay::load('node.article.default');
$options = $entity_form_display
->getComponent('body');
$this
->assertIdentical('content', $options['region']);
$entity_view_display = EntityViewDisplay::load('node.article.default');
$options = $entity_view_display
->getComponent('body');
$this
->assertIdentical('content', $options['region']);
}
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')));
};
$assertion([
'weight',
'region',
]);
$this
->runUpdates();
$assertion([
'weight',
'region',
'settings',
'third_party_settings',
]);
}
}