function ExtraFieldUpdatePathTest::testRunUpdates

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\Update

Code

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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.