public function ExtraFieldUpdatePathTest::testRunUpdates in Drupal 8
Tests the upgrade path for Layout Builder extra fields.
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ Update/ ExtraFieldUpdatePathTest.php, line 30
Class
- ExtraFieldUpdatePathTest
- Tests the upgrade path for Layout Builder extra fields.
Namespace
Drupal\Tests\layout_builder\Functional\UpdateCode
public function testRunUpdates() {
// The default view mode has Layout Builder enabled.
$data = EntityViewDisplay::load('node.article.default')
->toArray();
$this
->assertArrayHasKey('third_party_settings', $data);
$this
->assertArrayNotHasKey('sections', $data['third_party_settings']['layout_builder']);
// The teaser view mode does not have Layout Builder enabled.
$data = EntityViewDisplay::load('node.article.teaser')
->toArray();
$this
->assertArrayNotHasKey('third_party_settings', $data);
$this
->runUpdates();
// The extra links have been added.
$data = EntityViewDisplay::load('node.article.default')
->toArray();
$components = $data['third_party_settings']['layout_builder']['sections'][0]
->getComponents();
$component = reset($components);
$this
->assertSame('extra_field_block:node:article:links', $component
->getPluginId());
// No extra links have been added.
$data = EntityViewDisplay::load('node.article.teaser')
->toArray();
$this
->assertArrayNotHasKey('third_party_settings', $data);
}