You are here

public function LayoutBuilderEnableUpdatePathTest::testRunUpdates in Drupal 8

Tests the upgrade path for enabling Layout Builder.

File

core/modules/layout_builder/tests/src/Functional/Update/LayoutBuilderEnableUpdatePathTest.php, line 31

Class

LayoutBuilderEnableUpdatePathTest
Tests the upgrade path for enabling Layout Builder.

Namespace

Drupal\Tests\layout_builder\Functional\Update

Code

public function testRunUpdates() {
  $assert_session = $this
    ->assertSession();
  $expected = [
    'sections' => [
      [
        'layout_id' => 'layout_onecol',
        'layout_settings' => [],
        'components' => [
          'some-uuid' => [
            'uuid' => 'some-uuid',
            'region' => 'content',
            'configuration' => [
              'id' => 'system_powered_by_block',
            ],
            'additional' => [],
            'weight' => 0,
          ],
        ],
        'third_party_settings' => [],
      ],
    ],
  ];
  $this
    ->assertLayoutBuilderSettings($expected, 'block_content', 'basic', 'default');
  $this
    ->assertLayoutBuilderSettings(NULL, 'node', 'page', 'default');
  $this
    ->runUpdates();

  // The display with existing sections is enabled while the other is not.
  $expected['enabled'] = TRUE;
  $expected['sections'][0]['layout_settings']['label'] = '';
  $this
    ->assertLayoutBuilderSettings($expected, 'block_content', 'basic', 'default');
  $this
    ->assertLayoutBuilderSettings(NULL, 'node', 'page', 'default');
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalGet('admin/structure/block/block-content/manage/basic/display');
  $assert_session
    ->checkboxChecked('layout[enabled]');
  $this
    ->drupalGet('admin/structure/types/manage/page/display');
  $assert_session
    ->checkboxNotChecked('layout[enabled]');
}